g++

final link failed: Invalid argument when including windows.h

為{幸葍}努か 提交于 2020-01-04 04:06:46
问题 I have set up MinGW and Eclipse with CDT for C++ developing on Windows. Everything works great until I #include <windows.h> . As soon as I do that, I get the linker error message c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: final link failed: Invalid argument whereby the path at the beginning resolves to C:/MinGW/mingw32/bin/ld.exe . I have no idea what the error message tries to tell me... so please help me to decrypt it. 回答1: Since I actually don't agree to Lol4t0's

ld: symbols not found for architecture x86_64

非 Y 不嫁゛ 提交于 2020-01-03 20:04:14
问题 and thank you for all help in advance. I am new to C/C++ and am teaching myself by throwing myself in the deep end. I am attempting to write a shared (static? not sure the difference) library and write a simple program to use said library. I am probably not doing this in the most efficient way (if it were Python, I'd be done with this project a week ago) but I am more concerned in knowing what and why I am doing things incorrectly. Again, thank you for all help: LinAlg.h //// PROTECT HEADER

Difference between “gcc -x c” and “gcc -x c++” assembly output

只谈情不闲聊 提交于 2020-01-03 19:01:16
问题 I have the following code in file main.c: int main() { int i; for (i = 0; i < 5; i++) { } return 0; } When I compile this with gcc -x c -m32 -S -O0 -o main.s main.c (under Fedora 16 64-bit) I get this output: .file "main.c" .text .globl main .type main, @function main: .LFB0: .cfi_startproc pushl %ebp .cfi_def_cfa_offset 8 .cfi_offset 5, -8 movl %esp, %ebp .cfi_def_cfa_register 5 subl $16, %esp movl $0, -4(%ebp) jmp .L2 .L3: addl $1, -4(%ebp) .L2: cmpl $4, -4(%ebp) jle .L3 movl $0, %eax leave

undefined reference to `shm_open' using CMake

余生长醉 提交于 2020-01-03 17:41:07
问题 I am using CMake under Ubuntu 14.04 to configure my project. I need to use a 3rd party library (say stuff.so). In the CMakeLists.txt, I use TARGET_LINK_LIBRARIES to link the stuff library. However, I got an error: DIR_TO_LIB/stuff.so:-1: error: undefined reference to `shm_open' I tried to put these flag in the CMakeLists.txt but it didn't work: set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lrt") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lrt") A post (link) saying that -lrt should be

explicit instantiation of function template fails (g++)

本秂侑毒 提交于 2020-01-03 16:48:58
问题 I am experiencing some problems (i.e, linkage errors) with explicit instantiation of a function template. Under Visual Studio the project links ok, only under g++/Unix, using Eclipse-CDT, the linkage produce errors. The function call is a part of a static library, which is linked with a dynamic library, in a big project. The architecture of the function is as follows: function template declared (but not implemented) inside a namespace in my MathUtils.h file. One of the function arguments is

How do I suppress C++ vtable generation for pure virtual classes using G++?

不羁岁月 提交于 2020-01-03 08:58:19
问题 Supressing C++ vtable generation can be done in MSVC using the __declspec(novtable) attribute. However, it seems that there is no equivalent attribute for the GNU C++ compiler. The fact is that leaving the vtables for pure virtual classes unnecessarily links in __cxa_abort() and many others, and I want to avoid this happening because I'm programming for an embedded system. So, what should I do? struct ISomeInterface { virtual void Func() = 0; }; class CSomeClass : public ISomeInterface {

Why doesn't using boost::tuple's .get work in template functions in gcc?

懵懂的女人 提交于 2020-01-03 08:53:23
问题 While trying to port some code to compile in linux I get peculiar compilation errors. Searching through the codebase I finally manage to get it down to the following code. 5: // include and using statements 6: template<typename RT, typename T1> 7: RT func(tuple<T1> const& t) { 8: return t.get<0>(); 9: } 10: // test code Trying to use it I get the error: test.cpp: In function <functionName>: test.cpp:8: error: expected primary-expression before ‘)’ token The code works fine in Visual Studio

g++: array bound is not an integer constant

风流意气都作罢 提交于 2020-01-03 07:37:08
问题 With the code, const double rotationStep = 0.001; const int N = 2*int(M_PI/rotationStep) + 3; static unsigned int counts[N]; g++ gives the error: array bound is not an integer constant before »]« token I am using g++ / gcc version 4.6.1 Can anybody tell me why g++ complains about the expression? 回答1: As of the ISO C++ standard of 2003, that's not an integral constant-expression . Quoting section 5.19 of the standard: An integral constant-expression can involve only literals (2.13),

Why does g++ warning about uninitialized variable depend on the type of the variable? (it warns for an int but not for a double)

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-03 07:34:16
问题 I'm currently trying to understand in which cases g++ warns about uninitialized variables. Consider the following piece of code: #include <iostream> typedef double barType; struct foo { barType bar; }; int main() { foo f; std::cout << f.bar << std::endl; } If I compile it like this I get no warning: $ g++ -O1 -Wall test.cc -o test but if I change barType to int: $ g++ -O1 -Wall test.cc -o test test.cc: In function ‘int main()’: test.cc:17: warning: ‘f.foo::bar’ is used uninitialized in this

cygwin g++ produces no output

一笑奈何 提交于 2020-01-03 05:57:05
问题 I just installed g++ from cygwin, when I try to compile a C++ file I am not getting any executable produced by the compiler, see example below. What's going wrong? Directory of C:\helloworld 01/02/2011 04:50 PM . 01/02/2011 04:50 PM .. 01/02/2011 04:48 PM 94 helloworld.cpp 1 File(s) 94 bytes 2 Dir(s) 24,658,272,256 bytes free C:\helloworld>g++-4 helloworld.cpp C:\helloworld>dir Volume in drive C is OS Volume Serial Number is C47B-942D Directory of C:\helloworld 01/02/2011 04:50 PM . 01/02