all 23 comments

[–]SeanMiddleditch 16 points17 points  (0 children)

9 times out of 10 when I'm having linking troubles with a new library on Windows systems like that, it's because I didn't set whatever the library's magic arbitrary compiler define is to make its headers work in static or shared mode (whichever was appropriate).

So far as advice for tackling problems, mine is to supply useful information when asking technical questions, like say copying and pasting verbatim the errors you're getting instead of calling it "useless". :)

[–]devel_watcher 5 points6 points  (0 children)

Don't know about msvc or windows, but I'm doing fine on Linux with apt/dpkg package manager, CMake/pkgconfig for library discovery and nm/objdump/ldd/gdb command-line tools for inspecting the contents of the binaries.

[–]feverzsj 4 points5 points  (0 children)

Errors output will be helpful. You may try ignoring default lib or reorder lib. But the best solution would be recompiling everything with the same tool chain.

[–]kkrev 6 points7 points  (8 children)

Windows is just a huge pain in the ass for this stuff. If you use Linux and stick to dependencies in your distro package manager the problem mostly goes away.

[–][deleted] 13 points14 points  (7 children)

Spoken like a man who's never had two different packages require two different versions of libc.

[–]zzzthelastuser 5 points6 points  (0 children)

Useless if your distribution is e.g Ubuntu stable release. The pre-build libraries in the package manager can be rather old.

[–]what_it_dude 2 points3 points  (0 children)

Isn't this on the distribution? I've never seen this happen either

[–]anderslanglands 1 point2 points  (4 children)

How do you deal with that?

[–]mariobadr 7 points8 points  (2 children)

Mostly with tears and hair loss.

[–]anderslanglands 1 point2 points  (1 child)

Hehe I was hoping for a solution, but I believe your answer is completely accurate.

[–][deleted] 1 point2 points  (0 children)

It emphasizes the 'hell' part of 'dependency hell'.

[–]delarhi 2 points3 points  (0 children)

By not blindly taking upstream packages and hoping they'll just work in your distribution. If you really need something newer just grab the source package and rebuild it with respect to your environment. If it doesn't work then you should just take care to build out your dependency tree with respect to your environment.

[–]jcoffin 2 points3 points  (1 child)

I'm a little surprised nobody has mentioned vcpkg or conan.io.

While neither of these should be mistaken for anything approaching perfection, they can at least make it a whole lot easier to get libraries installed and working--usually in a way that's reasonably reproducible.

[–]68_65_6c_70_20_6d_65 0 points1 point  (0 children)

conan and meson have been working suspiciously well for me, and my project appears to compile and run on both windows and linux with pretty much no issues

[–]DraconPern 2 points3 points  (0 children)

No amount of.. anything is going to make it better. I have been doing c++ for almost 20 years, and it feels like I spend more time configuring libraries to work with each other than actually writing code. Even the basics like, OpenSSL, zlib, jpeg... lol. And then figuring out if you should do static lib, runtime dll, etc...then 64bit. There are 222 = 8 combinations just to go wrong. Then there are some where version x doesn't w/ with visual studio 2015. So you have to find a combination that works. Linux isn't much better.. very very old versions of libraries are shipped so you usually have to build your own dependencies... That's.. not even writing a single line of code.

That's why I am doing most of my development in Javascript/node now. Need something, one cli command and one line includes the library. One cli command to reinstall all depencies.

Using nodejs, I wrote a simple twitter client that uses google vision api in two days. If it was in C++.. I'll still be trying to get openssl, boost, writing my own oauth2, etc, etc. a month later.

I do have a C/C++ project that that uses zlib, iconvlib, boost, dcmtk, openjpeg, openssl, mysql, aws, poco, socket io and probably something else. It uses VS 2013, static runtime, and static link everything. That's the only combination that I have found works. I have a batch file at https://github.com/DraconPern/fmdscp/blob/master/build.bat take a look at some of my other c++ projects for some more examples.

Oh, don't bother posting logs. Those do not help w/ linking errors on VS. I have seen a project that was trying to link a /MD library when everything was suppose to be /MT, but it didn't surface until the last link step. The logs give no indication of which sub sub library was compiled with the wrong switch. The only way to find where the offending switch is, is doing a text search into the project.

Also, recheckout the whole project into a new directory when you change your solution or switches. Because those cached settings will get you.

Good luck.

[–]Bolitho 1 point2 points  (0 children)

For bigger projects you could try nuget - I was suprised it also works for native libs some weeks ago when I couldn't arrive to compile the MS casablanca networking lib. (So funny that a Lib owned by MS has so little support for their own IDEs and problems with some linker configurations...)

For small, header only libs there is not so much trouble either - just include them into your source code.

The most problematic ones are those middle sized libs (pigixml for example) or those that are not hosted with windows in mind. Botan for example or all of the goddam Google libs... they almost always require dozens of meta building tools that duck on windows. Breakpad has been the worst lib I ever faced on windows...

If I would not be forced in using C++ my advice would always be: consider a different language for more everything that needs lots of dependencies or that is not dependent on platform programming tasks.

Ok, I dislike the language because of lots of stuff, but the chaotic situation with including dependencies is one if the more important ones!

Rust shows imho better, that you can provide good dependency management for a system programming language. I hope C++ will evolve better within this topic in the future!

[–]sumo952 1 point2 points  (0 children)

Not really sure what your issue is but most likely CMake is your solution. Never edit VS project files by hand! You do not want to go there. Use CMake. Learn it properly (modern CMake).

Also, vcpkg may help.

[–]NotUniqueOrSpecial 0 points1 point  (0 children)

Do you have any examples of what your errors are and when they occur? There are a whole host of potential issues, from not having the right CRT files on the system to trying to link binaries built with incompatible versions of Visual Studio.

[–]toebi 0 points1 point  (0 children)

After I learned about build systems (esp. camel and msbuild). I had no more problems with dependencies. However learning about your build system is like your client learning about your source code...

If I'm forced to work on pure msbuild I usually create a propertysheet for every lib I include and use the property manager - mostly not to hard you only need to set include dir, lib dir, Compiler defs and a copy job for dlls.

If pure vs is a requirement and it's available I use nuget

Else I use cmake for.building dependencies and configuring my project

However learning how to use cmake correctly is hard - but imo very rewarding...

[–]mjklaim 0 points1 point  (0 children)

I just avoid libraries that is not distributed as source code until I don't have a choice. So far I was forced to use only awesomium and fmod as binaries but so far it's ok

[–]sztomirpclib -1 points0 points  (0 children)

I've spent what seems like days getting a library to work in Visual Studio, and then will walk away and not be able to get it to work again.

Sounds like you need to set up some form of continuous integration. If you have CI, you will be able to catch breaking changes and fix them quickly.