I want to use pthread stuff in my static user library, but dependent projects won't link unless I add '-lpthread' to each project that uses it.
I would rather specify '-lpthread' in my own user library. Actually, I HAVE done that, but it doesn't do anything; I still need to add '-lpthread' to dependent projects, otherwise I get
Invoking: GCC C++ Linker
g++ <....>
/usr/bin/ld: /home/xxx/git/xxx/xxx.CUtil/Debug/libxxx.CUtil.a(EzyThread.o): undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
IMO it defeats the purpose of my own user library, if I also have to include its dependencies in the projects using it; what if I decide to use another internal mechanism instead of pthread?
I've used
#pragma comment(lib, "SomeOtherStuff.lib")
in MS VC which does what I want - but I'm now in a gcc environment. I checked out #pragma comment(lib, "xxx.lib") equivalent under Linux? which seemed high on emotion and low on usable info. Is there either something similar in gcc, or some other way to avoid specifying '-lpthread' in each dependent project? I know that C isn't OOP but why make each dependency have to work out how the user library is implemented?
(Please don't say that something like the #pragma method is longer than '-lpthread'. Note that the #pragma, or equivalent mechanism in my user library, is typed once, but the '-lpthread' is needed potentially hundreds of times, and needs changing as many times if the underlying mechanism in the user library changes.)