Reputation: 5812
I'm trying to compile a C++
project that includes the C
library SkelTrack which uses glib
Now, I get a whole bunch of the following errors:
LNK2019: unresolved external symbol _g_slice_alloc referenced in function _pqueue_new C:\....\pqueue.obj
LNK2019: unresolved external symbol _g_error_new referenced in function _skeltrack_skeleton_track_joints_sync skeltrack-skeleton.obj
LNK2019: unresolved external symbol _g_mutex_init referenced in function _skeltrack_skeleton_init skeltrack-skeleton.obj
LNK2019: unresolved external symbol _g_mutex_clear referenced in function _skeltrack_skeleton_finalize skeltrack-skeleton.obj
LNK2019: unresolved external symbol _g_mutex_lock referenced in function _skeltrack_skeleton_track_joints skeltrack-skeleton.obj
LNK2019: unresolved external symbol _g_mutex_unlock referenced in function _skeltrack_skeleton_track_joints skeltrack-skeleton.obj
LNK2019: unresolved external symbol _g_once_init_enter referenced in function _skeltrack_skeleton_get_type skeltrack-skeleton.obj
LNK2019: unresolved external symbol _g_once_init_leave referenced in function _skeltrack_skeleton_get_type skeltrack-skeleton.obj
Link to SkelTrack code referencing glib
: https://github.com/joaquimrocha/Skeltrack/blob/master/skeltrack/pqueue.c#L34
I must say that my understanding of the compilation process—especially on Windows—is quite vague, but here are some points of what I think is relevant information:
glib 2.36
through NuGet.glib
since earlier versions; so I don't think that's the problem.C89
because that's what VS likes best. I had to fix a few declarations that weren't at the beginning of the block.EDIT
C:[...]\packages\glib.2.36.2.11\build\native\lib\v110\Win32\Debug\dynamic
under VC++ Directories -> Library Directories
This folder contains glib-2.0.lib
.EDIT 2
I have uninstalled the NuGet glib
, downloaded glib
for Win32 manually and added the include
and lib
to the project config (C/C++ Additional Include and VC++ Library Directories, respectively).
I got all kinds of syntax errors like:
C2143: syntax error : missing '{' before 'const' c:\[....]\glib-dev\include\glib-2.0\glib\gutils.h 122
But they were fixed using this tip:
In gutils.h lines 82 and 122, and in gstring.h line 129, change "static inline" to "static __inline".
And now I'm back to the unresolved external
errors.
EDIT: ANSWER?
I was forgetting to add glib-2.0.lib
, gio-2.0.lib
, etc. to
Linker > Input > Additional Dependencies
Upvotes: 1
Views: 4542
Reputation:
I had a similar fight with Visual Studio 2015, and I managed to get the NuGet package working; here's what I did:
glibconfig.h
(I added it to lib\Glib23\include
).Go to the "VC++ Directories" in Configuration Properties and add the following to "Library References":
$(SolutionDir)packages\glib.2.36.2.11\build\native\lib\v110\$(Platform)\$(Configuration)\dynamic
In "C/C++" add the following to "Additional Include Directories":
$(SolutionDir)lib\Glib23\include
$(SolutionDir)packages\glib.2.36.2.11\build\native\include
The first line should be the location where you put glibconfig.h
Now in "Linker" add to "Additional dependencies":
glib-2.0.lib gio-2.0.lib gmodule-2.0.lib gobject-2.0.lib gthread-2.0.lib
You should be able to compile now, but the DLLs are still missing from the output folder so you can't run the program.
In "Build Events"/"Post-Build Event" set the command line to the following:
xcopy /y /d "$(SolutionDir)packages\glib.redist.2.36.2.11\build\native\bin\v110\$(Platform)\$(Configuration)\dynamic\*.dll" "$(OutDir)"
xcopy /y /d "$(SolutionDir)packages\libintl.redist.0.18.2.10\build\native\bin\v110\$(Platform)\$(Configuration)\dynamic\cdecl\*.dll" "$(OutDir)"
Now you should be able to run your program without manually compiling glib.
Upvotes: 4