1

I am trying to compile a visual c++ project in Visual Studio 2012 where I am adding a 3rd party library (libvlc.lib) to my project via the Properties >> Linker >> Input >> Additional Dependencies and adding the Library Directories entry in VC++ Directories section.

However, I am still getting unresolved external symbol errors with regards to the the API calls that exist in the library. I am not sure what I am doing wrong, whether I am missing some details. Any help with regards to this is greatly appreciated.

I also did a > dumpbin /EXPORTS libvlc.lib > lib.txt to see what the entries are and it contains all the API calls.

Here are screenshots of my dev environment: https://i.stack.imgur.com/JTxeq.png

jayboss
  • 61
  • 1
  • 10
  • 1
    Did you only add the *directory* where the library is, or did you add the *actual library* as well? – Some programmer dude Jan 21 '15 at 13:35
  • possible duplicate of [unresolved external symbol..no idea](http://stackoverflow.com/questions/9928238/unresolved-external-symbol-no-idea) – rrirower Jan 21 '15 at 13:44
  • Was one of the errors can not open `libvlc.lib`? If so are you mixing 32 and 64 bit? – drescherjm Jan 21 '15 at 13:52
  • I added the the following: Additional Dependencies -> libvlc.lib;strmbase.lib;kernel32.lib;... And the following to the Library Directories -> $PATH\folder\lib; The libvlc.lib exists in the folder\lib. – jayboss Jan 21 '15 at 14:36
  • No, I don't get the error of not opening libvlc.lib. – jayboss Jan 21 '15 at 14:38

4 Answers4

1

I just had this exact same problem. Posting my results in case someone else does too:

Compilation started at Fri Mar 27 15:38:37

devenv.com c:/Dev/Test/adu/adu.sln /build "Development|x64"

Microsoft (R) Microsoft Visual Studio 2012 Version 11.0.61030.0. Copyright (C) Microsoft Corp. All rights reserved.

1>------ Build started: Project: adu, Configuration: Development x64 ------ 1>adu.obj : error LNK2019: unresolved external symbol libvlc_new referenced in function main 1>adu_Development_x64_msd_v110\adu_d.exe : fatal error LNK1120: 1 unresolved externals

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The issue was indeed (as @drescherjm suggested in the comments), that I was trying to link a 32-bit build of libvlc.lib in 64-bit mode. Performing a 32-bit build fixed the issue:

Compilation started at Fri Mar 27 15:46:15

devenv.com c:/Dev/Test/adu/adu.sln /build "Development|Win32"

Microsoft (R) Microsoft Visual Studio 2012 Version 11.0.61030.0. Copyright (C) Microsoft Corp. All rights reserved.

1>------ Build started: Project: adu, Configuration: Development Win32 ------

1> adu.vcxproj -> c:\Dev\Test\adu\adu\adu_Development_x86_msd_v110\adu_d.exe ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Community
  • 1
  • 1
T.E.D.
  • 44,016
  • 10
  • 73
  • 134
0

you need to add the absolute path in the additional dependencies. For instance c:\your-drive\location\to\libfile\libvlc.lib

RC Brand
  • 429
  • 6
  • 10
  • If you have path of the lib in the `Library Directories` setting this is not required. – drescherjm Jan 21 '15 at 14:20
  • I tried both ways of adding absolute path, as well as only the file itself. – jayboss Jan 21 '15 at 14:39
  • can you post more information on this? are you using the same headers that the static libraries used? if so which version? what function are giving you linker errors for that version. send the screenshots of your additional linker settings and the folder location of the lib file. This information should be enough for first cut review – RC Brand Jan 21 '15 at 14:42
  • Yes, I am using the same header files as the library, you can find all the necessary header files and .dll + .lib files in the SDK folder of VLC in your Program Files directory. I cannot add images to SO since my rep is below 10, but here are links to the images http://imgur.com/s9KiYBp,62TNTYq,pxRcv5u,p5yPf9c – jayboss Jan 21 '15 at 16:19
  • Here is the dumpbin content of the libvlc.lib: `Dump of file libvlc.lib File Type: LIBRARY Exports name _libvlc_wait _libvlc_vprinterr _libvlc_vlm_stop_media ... _libvlc_new ... _libvlc_media_player_play...` So I know the API's exist in the library i am trying to link. – jayboss Jan 21 '15 at 16:24
0

Thanks for asking this and thank you all for answering, especially #T.E.D.! I kept getting these errors for external symbols when using libVLC, too, and I was compiling as x64 instead of x86 (32 bit). So I changed the configuration (Visual Studio) to 32bit, but still had errors, which I solved by simply creating a new 32 bit solution from scratch and copying the cpp code. Another solution might be linking problem: fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'.

Anyways, thanks! I'm posting this since it adds to T.E.D.'s solution which worked and may help others. Not sure why his answer was down-voted.

Community
  • 1
  • 1
JoeC
  • 71
  • 2
  • 6
0

This can be caused, like other answers have mentioned, by an architecture mismatch.

Instead of switching to 32-bit builds like the other answers have suggested, you can also use the 64-bit SDK, available at http://download.videolan.org/vlc/last/win64/.

hacker1024
  • 3,186
  • 1
  • 11
  • 31