I have problem using Code::Blocks with Mingw and STLport. A "hello, world" project doesn't link.
I try different settings of C::B but i have a linker errors
There is a code:
#include <vector>
#include <string>
#include <iostream>
int main()
{
std::vector<std::string> vec;
vec.push_back("hello cb");
std::cout << vec[0];
return 0;
}
there are errors:
F:/stlport/stlport/stl/_move_construct_fwk.h:104: undefined reference to `_imp___ZN11stlpmtx_std4coutE'
F:/stlport/stlport/stl/_move_construct_fwk.h:104: undefined reference to `_imp___ZN11stlpmtx_std12__node_alloc13_M_deallocateEPvj'
F:/stlport/stlport/stl/_move_construct_fwk.h:104: undefined reference to `_imp___ZN11stlpmtx_std8ios_base16_M_throw_failureEv'
F:/stlport/stlport/stl/_move_construct_fwk.h:104: undefined reference to `_imp___ZN11stlpmtx_std24__stl_throw_length_errorEPKc'
F:/stlport/stlport/stl/_move_construct_fwk.h:104: undefined reference to `_imp___ZN11stlpmtx_std12__node_alloc11_M_allocateERj'
collect2: ld returned 1 exit status
I have Mingw 3.4.5, C::b rev 3558 (31.01) and STLPort 5.1.0
P.S. Sorry for my English.
- link with the STLport library
- use multithreading by specifying -mthreads in "Build options => Compiler/Linker => Other Options"
- don't forget, that if you use multithreading, your executable needs the mingwm10.dll, that is in your MinGW bin directory
Thank you very much, but solve this problem myself. But i have another question, does gcc support auto link?
I have downloaded new C::B build and application witch build within STLport fails with runtime error. SIGSEGV, Segmentation fault, what it means and how fix it?
Quote from: alifehpp on February 03, 2007, 07:22:24 PM
SIGSEGV, Segmentation fault, what it means and how fix it?
Hello,
May be this website could help you:
http://en.wikipedia.org/wiki/Segmentation_fault
Also search with google for e.g., "SIGSEGV, Segmentation fault". You should find helpful information :).
Best wishes,
Michael
Thank you, under Visual Studio it called access violation. But why STLport fails under MinGW and not under VS8?
If not use iostreams, all works perfectly. I wonder.
Quote from: alifehpp on February 03, 2007, 09:52:35 PM
Thank you, under Visual Studio it called access violation. But why STLport fails under MinGW and not under VS8?
If not use iostreams, all works perfectly. I wonder.
Just my two cents worth. Reading or Writing to an unopened file can cause all sorts of faults.
Quote from: alifehpp on February 03, 2007, 09:52:35 PM
Thank you, under Visual Studio it called access violation. But why STLport fails under MinGW and not under VS8?
If not use iostreams, all works perfectly. I wonder.
Hello,
GCC and VS8 C++ are two different compilers more or less ISO C++ compliant.
Regarding your problem, did you check that everything is installed correctly (MinGW+binutil+win api, C::B, etc.)? Did you set the path to every include file and library in C::B?
You can try with a newer C::B revision...
Also give a try to a google search with "MinGW with STL Port". With a bit of luck, you should get helpful info.
Best wishes,
Michael
Did you copy the STL DLLs to the project folder that contains the exe?
Tim S
Your test hello world worked for me with STLport STLport-5.0.3, note it did need the DLL for libstlport.5.0.dll to work. Below is my compile commands.
Note, the readme stated that STLport includes must before the normal includes.
-------------- Build: Release in helloworld ---------------
mingw32-g++.exe -Wall -O2 -mthreads -IC:\apps\MinGW_GCC_3.4.5_API_3_8_STLport\STLport\stlport -IC:\apps\MinGW_GCC_3.4.5_API_3_8_STLport\include -c C:\CodeProjects\CodeBlocksProjects\CodeBlocks\CB_SVN_TEST\codeblocks-head-test\codeblocks\src\tests\STLport\helloworld\helloworld.cpp -o obj\Release\helloworld.o
C:/apps/MinGW_GCC_3.4.5_API_3_8_STLport/STLport/stlport/stl/_uninitialized.h: In member function `void stlp_std::vector<_Tp, _Alloc>::_M_insert_overflow_aux(_Tp*, const _Tp&, const stlp_std::__false_type&, size_t, bool) [with _Tp = stlp_std::string, _Alloc = stlp_std::allocator<stlp_std::string>]':
C:/apps/MinGW_GCC_3.4.5_API_3_8_STLport/STLport/stlport/stl/_uninitialized.h:239: warning: '__cur' might be used uninitialized in this function
mingw32-g++.exe -LC:\apps\MinGW_GCC_3.4.5_API_3_8_STLport\STLport\lib -LC:\apps\MinGW_GCC_3.4.5_API_3_8_STLport\lib -o bin\Release\helloworld.exe obj\Release\helloworld.o -s -lstlport.5.0.dll
Info: resolving stlp_std::cout by linking to __imp___ZN8stlp_std4coutE (auto-import)
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 1 warnings
Installed STLport-5.1.0 and it also worked.
Tim S
-------------- Build: Release in helloworld ---------------
mingw32-g++.exe -Wall -O2 -mthreads -IC:\apps\MinGW_GCC_3.4.5_API_3_8_STLport\STLport-5.1.0\stlport -IC:\apps\MinGW_GCC_3.4.5_API_3_8_STLport\include -c C:\CodeProjects\CodeBlocksProjects\CodeBlocks\CB_SVN_TEST\codeblocks-head-test\codeblocks\src\tests\STLport\helloworld\helloworld.cpp -o obj\Release\helloworld.o
C:/apps/MinGW_GCC_3.4.5_API_3_8_STLport/STLport-5.1.0/stlport/stl/_uninitialized.h: In member function `void stlp_std::vector<_Tp, _Alloc>::_M_insert_overflow_aux(_Tp*, const _Tp&, const stlp_std::__false_type&, size_t, bool) [with _Tp = stlp_std::string, _Alloc = stlp_std::allocator<stlp_std::string>]':
C:/apps/MinGW_GCC_3.4.5_API_3_8_STLport/STLport-5.1.0/stlport/stl/_uninitialized.h:247: warning: '__cur' might be used uninitialized in this function
mingw32-g++.exe -LC:\apps\MinGW_GCC_3.4.5_API_3_8_STLport\STLport-5.1.0\lib -LC:\apps\MinGW_GCC_3.4.5_API_3_8_STLport\lib -o bin\Release\helloworld.exe obj\Release\helloworld.o -s -lstlport.5.1.dll
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 1 warnings
I used MSys to build the libs and I used the commands below to compile the libs.
From the README file steps for GNU Make (Linux, OpenBSD, FreeBSD, CygWin, etc.), with gcc:
make -f gcc.mak depend
make -f gcc.mak install
Note, STLport-5.0.3 seems to work better than STLport-5.1.0.