-
LNK error message
Hello,
I am trying to get a C++ program call a Prolog program (in VS2008 IDE).
To make all the Prolog header files available to VS2008, I have copied all the include files onto my VC include folder, such as SWI_Prolog.h, SWI-cpp.h, plterm.h, etc.
However, when I build and compile my program, I get this error:
error LNK2019: unresolved external symbol _PL_new_term_ref . . .
I made sure the error is caused by this line:
goal_term = PL_new_term_ref();
It wouldn't complain when I put:
term_t goal_term;
in my program's header file in the private variables section, but it wouldn't accept this line:
goal_term = PL_new_term_ref();
in my main program. Any idea why I get this error message?
Thank you,
-
Do you have this Prolog source files? If so, add them to the project.
If not, then I assume you have a library (ie DLL file)? Then you must also have a .lib file. Add this under linker -> input under project options.
The why is that you are calling a function that doesn't exist anywhere in your project, but you told the compiler it existed (ie you lied).
-
Next to the header files (SWI_Prolog.h etc), were there any library files (.a, .lib, .dll) ?
The header file only tells the compiler what it needs to know to be able to call a function.
It's the library proper that does the actual work (and is in the domain of the linker).
-
I added these lines:
#pragma comment(lib, "libpl.lib")
#pragma comment(lib, "plterm.lib")
#pragma comment(lib, "pthreadVC.lib")
#pragma comment(dll, "libpl.dll")
#pragma comment(dll, "plterm.dll")
#pragma comment(dll, "pthreadVC.dll")
to my source file, but now I get this error message:
Unhandled exception at 0x0054870f in myProg.exe:
0xC0000005: Access violation reading location 0x000000c.
And then there are two choices of Break and Continue.
Do I need to add anything else, or this error message is yet another indication that I am doing something (else) wrong?
Thanks for your help,
-
Now you've reached the stage of having a running program.
But it has a bug in it which causes it to access an illegal memory location.
Now the fun really starts - debugging!
Pressing break should drop you in the debugger at the point of the problem. Hopefully from looking around you can figure out what went wrong.
From the look of things, you've got ptr->someMember where ptr happens to be NULL.