g++

libmysqlclient.a is nowhere to be found

房东的猫 提交于 2019-12-22 10:29:32
问题 On an Amazon EC2 ( uname -r gives "3.4.37-40.44.amzn1.x86_64", which I hear is based on Cent OS) I tried installing: yum install mysql yum install mysql-devel And even yum install mysql-libs (Due to this thread.) I'm trying to compile a program and link the MySQL libraries to it. This works fine on my Mac, (but the Mac has libmysqlclient.a ). libmysqlclient.a is absolutely nowhere to be found on this machine. All it has is libmysqlclient.so , and many versions of it too. $ sudo find / -name

‘cout’ is not a member of ‘std’ & ‘cout’ was not declared in this scope

无人久伴 提交于 2019-12-22 09:47:19
问题 I realize that there are several duplicates like this but none of them have worked for me so far. I am trying to compile a C++ very simple program on Ubuntu using g++ but it is giving me scope errors. #include <iostream> using namespace std; int main() { cout << "Hello world"; } This gives me this error: sudo g++ -v test.c test.c: In function ‘int main()’: test.c:7:3: error: ‘cout’ was not declared in this scope I also tried defining the scope as many other posts say, but that also didn't

Why won't gcc compile uninitialized global const?

安稳与你 提交于 2019-12-22 09:37:22
问题 When I try to compile the following with g++: const int zero; int main() { return 0; } I get an error about an uninitialized const 'zero' . I thought that global variables were default initialized to 0 [1] ? Why isn't this the case here? VS compiles this fine. [1] For example, see https://stackoverflow.com/a/10927293/331785 回答1: My gcc is slightly more verbose: $ g++ zeroconst.c zeroconst.c:1:11: error: uninitialized const ‘zero’ [-fpermissive] We see that -fpermissive option will allow this

Why won't gcc compile uninitialized global const?

て烟熏妆下的殇ゞ 提交于 2019-12-22 09:32:41
问题 When I try to compile the following with g++: const int zero; int main() { return 0; } I get an error about an uninitialized const 'zero' . I thought that global variables were default initialized to 0 [1] ? Why isn't this the case here? VS compiles this fine. [1] For example, see https://stackoverflow.com/a/10927293/331785 回答1: My gcc is slightly more verbose: $ g++ zeroconst.c zeroconst.c:1:11: error: uninitialized const ‘zero’ [-fpermissive] We see that -fpermissive option will allow this

decltype(*&fun) is strange?

无人久伴 提交于 2019-12-22 08:42:09
问题 I have: #include <type_traits> #include <stdio.h> void f() { printf("foo\n"); } int main() { printf("%d %d %d\n", std::is_same<decltype(*&f),decltype(f)>::value, std::is_function<decltype(*&f)>::value, std::is_function<decltype(f)>::value); (*&f)(); return 0; } which yields 0 0 1 foo on g++ 4.6.1 and 4.7.0. Can anyone explain this to me? 回答1: It's important to note that decltype has two meanings: it can be used to find the declared type (hence its name) of an entity , or it can be used to

Has anyone an example for wrapping a function in C++?

拜拜、爱过 提交于 2019-12-22 08:11:55
问题 I have searched online a lot but I couldn't find an example that works with g+, all examples work with GCC. The error I keep getting is: wrap_malloc.o: In function `__wrap_malloc(unsigned int)': wrap_malloc.cc:(.text+0x20): undefined reference to `__real_malloc(unsigned int)' wrap_malloc.o: In function `main': wrap_malloc.cc:(.text+0x37): undefined reference to `__wrap_malloc' collect2: ld returned 1 exit status The code that creates this error is the following (this code works if I compile

how to dynamically link to local copy of libc.so.6, libstdc++.so.6 on system with old version of gcc

时光怂恿深爱的人放手 提交于 2019-12-22 07:58:08
问题 my code is written in c++2011 and compiled in g++ 4.8. however, my sysadmin won't upgrade the compute cluster from gcc/g++ 4.1. i get the following error: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./ManRegOptDes) /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.17' not found (required by ./ManRegOptDes) /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by ./ManRegOptDes) /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by .

g++: No Such Instruction with AVX

白昼怎懂夜的黑 提交于 2019-12-22 07:07:17
问题 When I compiled a program I was writing in C++ (for the latest Macbook pro, which of course supports the AVX instruction set), I got the following errors. I am using the latest release of g++ obtained from Macports. Do you have any ideas as to what I can do to fix the error without restricting the instruction sets available to the compiler? Is there any package in particular that I should try to update? g++-mp-4.7 -std=c++11 -Wall -Ofast -march=native -fno-rtti src/raw_to_json.cpp -o bin/raw

Why doesn't g++ link with the dynamic library I create?

孤人 提交于 2019-12-22 06:29:38
问题 I've been trying to make some applications which all rely on the same library, and dynamic libraries were my first thought: So I began writing the "Library": /* ThinFS.h */ class FileSystem { public: static void create_container(string file_name); //Creates a new container }; /* ThinFS.cpp */ #include "ThinFS.h" void FileSystem::create_container(string file_name) { cout<<"Seems like I am going to create a new file called "<<file_name.c_str()<<endl; } I then compile the "Library" g++ -shared

ignoring packed attribute because of unpacked non-POD field

谁都会走 提交于 2019-12-22 05:50:10
问题 The following code gives me this error when compiled with avr-g++ compiler ignoring packed attribute because of unpacked non-POD field 'float& foo::BAR' what is the reason? class foo { public: foo(float &bar); private: float &BAR; }; foo::foo(float &bar):BAR(bar) { } int main() { float something; foo fooobject(something); } 回答1: It appears to be a compiler bug : https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58798. 回答2: I don't know about your case in particular, but just to clarify for other