g++

CMake can not find g++ compiler on Windows

浪尽此生 提交于 2021-02-04 16:08:41
问题 I have a CMake project I want to compile with g++. The project compiles and runs on Linux. Now I am trying to get it working on Windows. For that reason, I installed MinGW and added it to the PATH and I am using Git Bash. In order to force CMake to use g++ I added these env variables: CC = C:\MinGW\bin\gcc CXX = C:\MinGW\bin\g++ But when I run CMake it does not detect any compilers and tells me: -- The C compiler identification is unkown -- The CXX compiler identification is unkown I created

CMake can not find g++ compiler on Windows

只愿长相守 提交于 2021-02-04 16:08:39
问题 I have a CMake project I want to compile with g++. The project compiles and runs on Linux. Now I am trying to get it working on Windows. For that reason, I installed MinGW and added it to the PATH and I am using Git Bash. In order to force CMake to use g++ I added these env variables: CC = C:\MinGW\bin\gcc CXX = C:\MinGW\bin\g++ But when I run CMake it does not detect any compilers and tells me: -- The C compiler identification is unkown -- The CXX compiler identification is unkown I created

CMake can not find g++ compiler on Windows

匆匆过客 提交于 2021-02-04 16:08:17
问题 I have a CMake project I want to compile with g++. The project compiles and runs on Linux. Now I am trying to get it working on Windows. For that reason, I installed MinGW and added it to the PATH and I am using Git Bash. In order to force CMake to use g++ I added these env variables: CC = C:\MinGW\bin\gcc CXX = C:\MinGW\bin\g++ But when I run CMake it does not detect any compilers and tells me: -- The C compiler identification is unkown -- The CXX compiler identification is unkown I created

OS X: installed gcc links to clang

假装没事ソ 提交于 2021-02-04 07:27:07
问题 I already have gcc and g++ install: $ which gcc /usr/bin/gcc $ which g++ /usr/bin/g++ $ brew install gcc Warning: gcc-6.2.0 already installed I follow Compile OpenMP programs with gcc compiler on OS X Yosemite to reinstall gcc via HomeBrew: $ brew reinstall gcc --without-multilib then $ /usr/bin/g++ openmp.cpp openmp.cpp:12:10: fatal error: 'omp.h' file not found #include <omp.h> ^ 1 error generated. with -fopenmp $ /usr/bin/g++ openmp.cpp -fopenmp clang: error: unsupported option '-fopenmp'

Issue with std::thread from c++11

亡梦爱人 提交于 2021-02-04 05:54:11
问题 I have some troubles trying to compile a program with multi-threading from the standard template library. It return me a obscure error when i try to compile the following program : #include <iostream> #include <thread> void foo() { std::cout << "Thread 1\n"; } int main(int argc, char** argv) { std::thread tr(foo); std::cout << "Main thread\n"; tr.join(); return 0; } I don't understand the error : /tmp/ccE8EtL1.o : In the function « std::thread::thread<void (&)()>(void (&)()) » : file.cpp:(

Issue with std::thread from c++11

﹥>﹥吖頭↗ 提交于 2021-02-04 05:51:57
问题 I have some troubles trying to compile a program with multi-threading from the standard template library. It return me a obscure error when i try to compile the following program : #include <iostream> #include <thread> void foo() { std::cout << "Thread 1\n"; } int main(int argc, char** argv) { std::thread tr(foo); std::cout << "Main thread\n"; tr.join(); return 0; } I don't understand the error : /tmp/ccE8EtL1.o : In the function « std::thread::thread<void (&)()>(void (&)()) » : file.cpp:(

Remove needless assembler statements from g++ output

橙三吉。 提交于 2021-01-29 14:31:16
问题 I am investigating some problem with a local binary. I've noticed that g++ creates a lot of ASM output that seems unnecessary to me. Example with -O0 : Derived::Derived(): pushq %rbp movq %rsp, %rbp subq $16, %rsp <--- just need 8 bytes for the movq to -8(%rbp), why -16? movq %rdi, -8(%rbp) movq -8(%rbp), %rax movq %rax, %rdi <--- now we have moved rdi onto itself. call Base::Base() leaq 16+vtable for Derived(%rip), %rdx movq -8(%rbp), %rax <--- effectively %edi, does not point into this area

g++: create a shared library (.so) with static glibc?

我与影子孤独终老i 提交于 2021-01-29 10:32:17
问题 I'm trying to create a shared library (.so file) that will include its own copy of glibc and link to it statically. I am already linking to libgcc and libstdc++ statically using -static-libgcc -static-libstdc++ in addition to -shared -fPIC and it works great. What combination of flags do I need to set to link to the static version of glibc as well? I tried adding -static to the lot but got this error: /usr/bin/ld: /home/.../x86_64-unknown-linux-gnu/4.6.2/crtbeginT.o: relocation R_X86_64_32

Compiler error with filesystem library: clang and g++

泪湿孤枕 提交于 2021-01-29 07:20:45
问题 I am writing a personal project in c++ which needs to access to files in some directories, hence I decided to use the filesystem library. I encountered some problems when I try to compile my project on MacOS and on Linux. The code snippet is the following #include <iostream> #include <fstream> int main(){ std::string path = "Inner"; std::cout << "Files in " << path << " directory :" << std::endl; for (const auto & entry : std::filesystem::directory_iterator(path)) std::cout << entry.path() <<

GetModuleInformation Fails on Linkage in Windows 10

旧街凉风 提交于 2021-01-29 06:39:21
问题 I am trying to create a DLL Injector that will directly execute functions within the DLL in the target process. I am trying to get the entry point of the DLL I injected so I can get the offset of the function. I read on the Microsoft Docs to use GetModuleInfo() . I used the header psapi.h and found that compilation worked, but it failed on linkage providing the following error: g++ dll_injector.cpp -o dll_injector.exe C:\Users\DELKAR~1\AppData\Local\Temp\ccOeKdhW.o:dll_injector.cpp:(.text