Hi,
I work with ubuntu 12.04 64bits
I have newly installed g++ 4.7, (the one with C++11 features)
I can compile a simple program on the command line with this pattern: g++-4.7 -std=c++11 tst_threads2.cpp -o tst_threads2 -lpthread
After several tests, I manages to have codeBlock compiling the same way. I used a specific build command as shown in the screen capture below.
(http://masla.smugmug.com/Photography-Forums/chassimages/i-WRpt3Gp/0/X3/Properties-of-main2cpp005-X3.png)
The code compiles now :D
The problem is it does not link.
I get the following message:
Compiling: main2.cpp
Linking console executable: bin/Debug/essai1
g++: fatal error: -fuse-linker-plugin, but liblto_plugin.so not found
compilation terminated.
Please do not expect any basic knowledge on codeBlock from myself. I am totally new to codeBlock.
Actually, I am trying to have C++11 compiling on either codeBlock and Eclipse. I will stick to the first one that will be running.
Thanks for reading,
Olivier
Alpha,
Many thanks for helping.
I have spent the entire day posting my problem to all the forums I could find on the Internet and you are the first to make me make a step forward.
I still have questions:
* I plugged the PPA and made a sudo apt-get update. The system actually downloaded some stuff from the new PPA but CodeBlock is still the 10.05. What did I miss?
* Thanks to your advices, I succeeded at compiling AND linking my hello world project.
* BUT: This multithread project hangs when starting the thread.
This is the code
#include <iostream>
#include <thread>
//This function will be called from a thread
void call_from_thread() {
std::cout << "Hello, from thread!" << std::endl;
}
int main() {
std::cout << "Hello, from main!" << std::endl;
//Launch a thread
std::thread t1(call_from_thread);
//Join the thread with the main thread
t1.join();
return 0;
}
This is the output
olivier@LISAH-OBOKERN:~/codeblocks_projects/essai1/bin/Debug$ ./essai1
Hello, from main!
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted
Aborted (core dumped)
and this is the output when compiled from the console:
olivier@LISAH-OBOKERN:~/codeblocks_projects/essai1$ g++-4.7 -std=c++11 main.cpp -o main -lpthread
olivier@LISAH-OBOKERN:~/codeblocks_projects/essai1$ ./main
Hello, from main!
Hello, from thread!
olivier@LISAH-OBOKERN:~/codeblocks_projects/essai1$
So, I conclude that something is still missing to CodeBlocks to allow multithreading programming. (single-thraded programs work fine, as far as I tested them)
Again, thanks for helping. I am new to CodeBlock, and so happy that some useful help came at last! :)