2

I am trying to build static libraries with the hopes of creating a portable executable. I was successful at building dynamic libraries using the following tutorial:

https://zahidhasan.wordpress.com/2013/02/16/how-to-install-opencv-on-windows-7-64bit-using-mingw-64-and-codeblocks/

I am essentially repeating the process, but with BUILD_SHARED_LIBS = OFF.

I build in CodeBlocks and it fails. The Build messages I get are a series of variations of the following (varying in d00xxxxxx):

C:\TDM-GCC-64\bin..\lib\gcc\x86_64-w64-mingw32\4.9.2\libstdc++.dll.a(d002386.o)|| first defined here|

The Build log shows:

C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2\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:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/libstdc++.dll.a(d002386.o):(.text+0x0): first defined here C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2\libstdc++.a(sstream-inst.o):sstream-inst.cc:(.text$_ZNKSt15basic_stringbufIcSt11char_traitsIcESaIcEE3strEv[_ZNKSt15basic_stringbufIcSt11char_traitsIcESaIcEE3strEv]+0x0): multiple definition ofstd::basic_stringbuf, std::allocator >::str() const' C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/libstdc++.dll.a(d000413.o):(.text+0x0): first defined here

Both of these repeat for the maximum allowed 50 errors.

Any help would be greatly appreciated.

11
  • I would try to see what happens starting from a clean build directory, and activating static library building from the beginning: your problem might be caused by some leftovers of the dynamic library build process. Commented Apr 2, 2015 at 21:24
  • My apologies if it was unclear. I have done that. I also tried building from the command line with mingw32-make instead of using codeblocks. It looks like it is trying to build compiler libraries as well, specifically 'libstdc++'. Is this normal? Commented Apr 2, 2015 at 21:28
  • It looks like a compiler/linker bug to me... Where did you download it? Commented Apr 2, 2015 at 21:40
  • You could try this sourceforge.net/projects/mingw-w64/files/… By the way, are you targetting 32 or 64 architecture? Commented Apr 2, 2015 at 21:44
  • I can't recall where I downloaded the compiler, I tried a couple until I found one that looked legit. I settled for what appears to be a TDM installer for mingw. I am targeting a 64bit system, but may also want the ability to port to 32 bit. Commented Apr 2, 2015 at 21:56

1 Answer 1

0

It looks like a compiler/linker bug to me...

You could try the toolchain available here. (Note: this link might be soon become outdated, so in general use the link below and browse to the most recent version)

And in general at http://sourceforge.net/projects/mingw-w64/files/ where you can also find toolchains targeting 32bit architectures.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. That's exactly what I did and it worked. The TDM version of Mingw64 seems to be defective. I have successfully created the static libraries, now am having issues with undefined references.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.