DSO missing from command line when use concurrent_queue of TBB - c++11

I'm trying to use TBB to video proces in the Qt project. But running the project it gives me some errors:
/usr/bin/ld: main.o: undefined reference to symbol '_ZN3tbb8internal24concurrent_queue_base_v3D2Ev'
//usr/lib/x86_64-linux-gnu/libtbb.so.2: error adding symbols: DSO missing from command line
When I searched for the error it says to .pro file edit adding: LIBS =-lpthread
but it is already there.
How do I should to resolve this error?

My problem was resolved by add LIBS+=-ltbb to .pro file.

I also had the same issue.......
and I use eclipse to write my c++ programs......
and i resolved my issue by adding a new entry 'tbb' under the eclipse c++ poject properties -> c/c++ Bild -> settings -> GCC c++ Linker -> Libraries -> Librarie(-l) section
Ans the same thing is shown in the following figure Added tbb in project property settings

Related

Bazel failed to include a external static library .a

-- Question solved --
This question is solved. Thanks for all the help!
The problem and the reason is briefly stated as following for other readers in the future:
[Environment]
Ubuntu 14.04, Bazel, C++
[Question]
I want to include an external library. So I download the source file and make it as as a static lib .a.
I correctly set the BUILD, WORKSPACE and related files. However, when compile, it alerts the error:
Linking of rule '//main' failed (Exit 1)
main: error: undefined reference to 'void ex_lib::compute(double*, double const*, double const*)'
collect2: error: ld returned 1 exit status
I tried with the .lo and alwayslink method here but doesn't work.
Alternate to "`--whole-archive`" in bazel
[Reason]
It is because that the external library source files contains duplicate header files. So I fix the header file problem. Make the .a again. Then everything works.
So nothing wrong with the bazel. It is the library itself that cause the problem. But the error information is confusing and I think it is caused by bazel.
What you can do to investigate further is to run the clean bazel build with --subcommands to see individual command lines of actions executed. Then you can cd into the sandbox, and execute the same gcc command as bazel does and debug what's wrong. Or you can try to get linking to work by handwriting gcc command, and pasting here both the command bazel generated, and your desired command. Is it possible that you have multiple liegroups libs installed on the system and gcc is getting one that's incompatible with headers you're including?
The problem is solved. Special thanks to mhlopko.
It is mainly because there is errors with the lib source file. Thus .a file I use contains errors. Now the bazel works fine with the new lib file.
By the way, now bazel works fine with both .a or .so file that I generated.

linking std::experimental::filesystem with Xcode 9

I am using std::experimental::filesystem with Xcode 9.0 beta. The compiler phase completes OK but the linker complains of undefined symbols:
std::experimental::filesystem::v1::path::__filename() const
std::experimental::filesystem::v1::path::__filename() const
std::experimental::filesystem::v1::path::__stem() const
std::experimental::filesystem::v1::__status(std::experimental::filesystem::v1::path const&, std::__1::error_code*)
I am also using std::experimental::filesystem::canonical(), but the linker isn't complaining about that being missing.
How can I configure the project to include these missing references?
UPDATE:
I have been experimenting with a simpler program. If I just use canonical() then the linker complains that it is missing.
I can use std::experimental::optional - everything compiles, links and runs OK. But 'optional' is a template and so probably doesn't involve a library.
Are you compiling with any -std= option ("C++ Language Dialect" option in Xcode)?

Building C++ static library to .a file for iOS. Undefined symbols for architecture armv7s: "std::__1::__vector_base_common:: ..."

I'm trying to build a .a file to include in a unity3d asset in order to let people build for iOS.
I get the following error when I try to build a game. (The error is a lot longer than this but it seems to be an issue with std::vector )
Building .a file for iOS. Undefined symbols for architecture armv7s: "std::__1::__vector_base_common:: ..."
I saw here Someon has the same error and the solution is .. "add the -lc++ linker flag to your target's Build Settings"
I've tried this fix in the poroject from which I build the .a file from. When I try to build the library I get this error
Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: -dynamic not specified the following flags are invalid: -ObjC
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lC++
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lC++ is not an object file (not allowed in a library)
Note: I'm very inexperienced with osx and xcode.

D Windows programming linker error

While trying to compile this program with an up-to-date compiler: https://github.com/AndrejMitrovic/DWinProgramming/blob/master/Samples/Chap03/HelloWin/HelloWin.d
I get this linker error: Error 42: Symbol Undefined _D5win327winuser13CreateWindowWFPxuPxukiiiiPvPvPvPvZPv
That's a mangled name, so the problem isn't the Windows libraries themselves... my guess is the dmd_win32.lib file from here https://github.com/AndrejMitrovic/DWinProgramming is needed too.
Try downloading that and adding it to your compile command line. dmd Hellowin.d dmd_win32.lib

How to link to another library in Xcode?

I created a command line application. Then I realized it would be handy to be able to use code in other projects, so I added a new target - a cocoa library.
It seems to compile and a .a file is generated.
Now in another project I want to use this library. So first I added the first project to this new project as a reference.
In build settings I set "Always search user paths" to YES, then keyed in the path to the above project in user header paths.
In build phases, "Link Binary with libraries" , I added the .a file.
Now in my new project code sense seems to work. But when I try to build, I get an error : ndefined symbols for architecture x86_64:
"_OBJC_CLASS_$_RIImageSplitter", referenced from:
objc-class-ref in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What did I do wrong? :S I am a beginner.
Didn't add file to compile sources of target. =S
Check this:
Did you drag the static library to your project navigator?
Did you add in Target/Build Phases/ Target Dependencies?
Did you add the Header Search Path for the headers of the static library?
Good Luck!

Resources