PDA

View Full Version : [C++] Any tutorial for library linking ?



KuroTenshi67
4th December 2016, 19:27
Gentlemen ! Greetings :)

So, the gist is as follows : on my journey to learn how to make C++ programs for later purposes regarding Mugen (sprite making is my first priority), I've attempted to build a C++ IDE composed of MinGW (for the compiler), Visual Studio, and the OpenCV module.
Aware that I've only made a few steps in my travel, I stumble upon an error message that I have many troubles trying to solve it : undefined reference to `cv::blahblahblah' (replace blahblahblah by FastFree(void), MatCreate,...).
After some first researches on what it could mean in terms of causality, I've learnt that it's due to an error of library linking.
And there, it became hard : after tinkerings with environment variables, parameters with the "-L" flags, cutting-and-pasting libraries here and there in lib directories, nothing.
All I could do is open the command prompt, and type "hoist.exe -White" to raise the white flag following fruitless hours.

So, after this paragraph written in a way that resembles C++ ... complexity, I leave my ears eyes open to any suggestion of a tutorial that could scatter the fog I'm crossing.
With my early gratitude, have a good day :)

taiyu
6th December 2016, 15:27
mingw uses GCC so you generally need 2 options to add libraries.
tell the compiler to check the directory the library is in
-Ldirectory/of/library
and tell it to use a certain library. if its name is something like libfoo.dll/so just use -lfoo
-lname_of_library

also this could help.
http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use

i dont use windows so there might be some other details im not sure about, specially with visual studio.

KuroTenshi67
7th December 2016, 20:55
Gotta try that again tomorrow with the link you've sent me. Thanks ;)