Hello,
I installed cLion and MinWG on windows 10, and replicated the hello example (https://www.swi-prolog.org/pldoc/man?section=shlib ).
When running: swipl-ld -o library
I get an error:
undefined reference to `WinMain@16’
collect2.exe: error: ld returned 1 exit status
gcc.exe returned code 1
*** swipl-ld exit status 1
Just compiling it in cLion works without error.
According to stackoverflow i may be missing an entry point recognized by windows, but i create this project as a library.
any thoughts are much appreciated,
thank you,
Dan
jan
June 14, 2020, 7:11am
2
This at least suggests you didn’t really compile for a dll, but for an exe. Being gcc, a trivial example should be something like this:
gcc -shared -o myplugin.dll -I<path to SWI-Prolog.h> -L<path to libswipl.dll> -l libswipl myplugin.c
thank you.
I added the SHARED keyword into the cmake file definition, with the assumption that this would generate the right options for gcc.
add_library(etry SHARED library.h library.cpp)
I guess, since i am using swipl-ld I don’t directly control the options.
So, i can use the gcc you mentioned instead of swip-ld … it does the same thing.
thanks,
Dan
jan
June 14, 2020, 7:23am
4
swipl-ld simply uses gcc. Add -v
too see how it calls the various steps. In a rather standard environment as Linux this works fine, but in Windows there are so many different C compilers that it can easily do the wrong thing.