Ask Your Question
0

static link fails with "multiple definitions" error

asked 2014-10-08 14:51:27 -0600

houmanr gravatar image

hi there

I am trying to compile opencv 3 statically on windows 7 64 bit using MinGW TDM 64 bit version. I use cmake and i check off the "shared" option before I begin the compilation. During compilation, around 43% progress point, I get the following errors:

Linking CXX executable ..\..\bin\opencv_perf_core.exe
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1\libstdc++.a(sstream-inst.o):sstream-inst.cc:(.text$_ZNSt19basic_ostringstreamIcSt11char_traitsIcESaIcEED1Ev[_ZNSt19basic_ostringstreamIcSt11char_traitsIcESaIcEED1Ev]+0x0): multiple definition of `std::basic_ostringstream<char, std::char_traits<char="">, std::allocator<char> >::~basic_ostringstream()'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/libstdc++.dll.a(d002421.o):(.text+0x0): first defined here
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1\libstdc++.a(sstream-inst.o):sstream-inst.cc:(.text$_ZNSt19basic_istringstreamIcSt11char_traitsIcESaIcEED1Ev[_ZNSt19basic_istringstreamIcSt11char_traitsIcESaIcEED1Ev]+0x0): multiple definition of `std::basic_istringstream<char, std::char_traits<char="">, std::allocator<char> >::~basic_istringstream()'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/libstdc++.dll.a(d002405.o):(.text+0x0): first defined here
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1\libstdc++.a(sstream-inst.o):sstream-inst.cc:(.text$_ZNSt18basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev[_ZNSt18basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev]+0x0): multiple definition of `std::basic_stringstream<char, std::char_traits<char="">, std::allocator<char> >::~basic_stringstream()'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/libstdc++.dll.a(d002382.o):(.text+0x0): first defined here
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1\libstdc++.a(sstream-inst.o):sstream-inst.cc:(.text$_ZNKSt15basic_stringbufIcSt11char_traitsIcESaIcEE3strEv[_ZNKSt15basic_stringbufIcSt11char_traitsIcESaIcEE3strEv]+0x0): multiple definition of `std::basic_stringbuf<char, std::char_traits<char="">, std::allocator<char> >::str() const'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/libstdc++.dll.a(d000415.o):(.text+0x0): first defined here
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1\libstdc++.a(sstream-inst.o):sstream-inst.cc:(.text$_ZNSt15basic_stringbufIcSt11char_traitsIcESaIcEE7_M_syncEPcyy[_ZNSt15basic_stringbufIcSt11char_traitsIcESaIcEE7_M_syncEPcyy]+0x0): multiple definition of `std::basic_stringbuf<char, std::char_traits<char="">, std::allocator<char> >::_M_sync(char*, unsigned long long, unsigned long long)'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/libstdc++.dll.a(d002216.o):(.text+0x0): first defined here
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1\libstdc++.a(sstream-inst.o):sstream-inst.cc:(.text$_ZNSt19basic_ostringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_Openmode[_ZNSt19basic_ostringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_Openmode]+0x0): multiple definition of `std::basic_ostringstream<char, std::char_traits<char="">, std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/libstdc++.dll.a(d002417.o):(.text+0x0): first defined here
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1\libstdc++.a(sstream-inst.o):sstream-inst.cc:(.text$_ZNSt18basic_stringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_Openmode[_ZNSt18basic_stringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_Openmode]+0x0): multiple definition of `std::basic_stringstream<char, std::char_traits<char="">, std::allocator<char> >::basic_stringstream(std::_Ios_Openmode)'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/libstdc++.dll.a(d002378.o):(.text+0x0): first defined here
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1\libstdc++.a(ios-inst.o):ios-inst.cc:(.text$_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate[_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate]+0x0): multiple definition of `std::basic_ios<char, std::char_traits<char=""> >::clear(std::_Ios_Iostate)'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/libstdc++.dll.a(d002756.o):(.text+0x0): first defined here
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1\libstdc++.a(ios-inst.o):ios-inst.cc:(.text$_ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E[_ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E]+0x0): multiple definition of `std::basic_ios<char, std::char_traits<char ...
(more)
edit retag flag offensive close merge delete

Comments

it seems someone has filed a bug report as well: http://code.opencv.org/issues/3759

houmanr gravatar imagehoumanr ( 2014-10-08 14:54:22 -0600 )edit

i tried using -static-libgcc -static-libstdc++ for CMAKE_CXX_FLAGS to no avail

houmanr gravatar imagehoumanr ( 2014-10-08 15:19:35 -0600 )edit

i seem to have fixed it by going through a lot of the "link.txt" files and manually changing all instances of "-lstdc++" with "-static-libstdc++" and it seems to be working. Im sure there is a way to do this from cmake but i did not figure it out.

houmanr gravatar imagehoumanr ( 2014-10-08 16:40:09 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-02-29 16:47:50 -0600

houmanr gravatar image

two years later and still having the same problem! the new solution for me was to remove ipp build options from cmake and also add the following : SET(CMAKE_EXE_LINKER_FLAGS "-static")

or just change the "CMAKE_EXE_LINKER_FLAGS" in the cmake options

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-10-08 14:51:27 -0600

Seen: 3,302 times

Last updated: Feb 29 '16