g++

Loading JNI .DLL, GCC compiled works, G++ compiled fails

北城余情 提交于 2019-12-12 01:05:48
问题 I have a simple JNI .DLL that I am trying to use in a test Java application. It is a .c file that consists of a couple functions, with the header generated by javah . (I am compiling using MinGW btw) If I compile and link this code with GCC, I can load the .DLL just fine with System.loadLibrary(), and use it. If I compiled it with G++ however, loadLibrary() will fail with the dreaded "UnsatisfiedLinkError". This is my GCC line: gcc -Wl,--add-stdcall-alias -I"C:\Program Files (x86)\Java\jdk1.7

mac os: g++ failed to add framework support

你离开我真会死。 提交于 2019-12-12 00:42:47
问题 Code: #include <Security/Security.h> int main() { } Compile: $ /Developer/usr/bin/g++ test.cpp -framework Security test.cpp:1:31: error: Security/Security.h: No such file or directory Or: $ /Developer/usr/bin/g++ test.cpp -F /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Security.framework/ test.cpp:1:31: error: Security/Security.h: No such file or directory System Info Mac: 10.6.5 Xcode: 3.2.5 G++: i686-apple-darwin10-g++-4.2.1 回答1: Since one day has passed and no one answered my

Combining multiple .o files into an executable

女生的网名这么多〃 提交于 2019-12-12 00:13:03
问题 I'm trying to combine object files created from C++ files into an executable using gcc . Unfortunately, gcc is giving me thousands of undefined reference errors to strings, arrays, etc. I am doing this on a Windows machine, so no terminal commands; only cmd commands. I'm simply doing: gcc a.o b.o c.o -o prgm.exe What am I missing/doing wrong? EDIT: I recreated the .o files with g++ doing: g++ a.cpp -g -c -Wall -std=c++0x -lSDLmain -lSDL -lSDL_image -lSDL_ttf -IC:\SDL-1.2.14\include -o a.o ,

gcc command line on Mac OS X with XCode 2.5

我们两清 提交于 2019-12-11 23:01:32
问题 I am currently running a MacBook Pro with Mac OS X Version 10.5.8. I downloaded XCode version 2.5 and installed it. Further, I added /XCode2.5/usr/bin to my PATH. Here is hello.cc program: #include <iostream> int main(void) { std::cout << "hello, world" << std:endl; } Here is what happens: $> g++ hello.cc hello.cc: In function ‘int main()’: hello.cc:5: error: ‘cout’ is not a member of ‘std’ hello.cc:5: error: ‘endl’ is not a member of ‘std’ Is setting the PATH not sufficient to run the gcc

Object file not created after building

☆樱花仙子☆ 提交于 2019-12-11 22:15:57
问题 I am getting an error when I am compiling my project on Eclipse Kepler. The project builds successfully, but the object is unsuccessfully created. I am getting the following output on my console 23:13:32 **** Build of configuration Debug for project Dictionary **** make all Building file: ../src/Diction.cpp Invoking: GCC C++ Compiler g++ -O0 -g3 -Wall -c -fmessage-length=0 -MM -MMD -MP -MF"src/Diction.d" -MT"src/Diction.d" -o "src/Diction.o" "../src/Diction.cpp" Finished building: ../src

Eclipse CDT fails to run compiled executable in Windows with error “terminated, exit value: <some number>”

时光总嘲笑我的痴心妄想 提交于 2019-12-11 21:22:51
问题 I just reinstalled Windows on my machine. Before that, I was using the Eclipse CDT IDE for Windows (64-bit) with MinGW compiler suite (downloaded using mingw-get). Everything worked perfectly fine before the reinstall. After the installation I tried to compile and run my C++ projects, but I always got the terminated, exit value: <some number> error in the console, even for a Hello World! project. I also got an error saying the libgcc_s_dw2-1.dll is missing from my computer when I tried to run

Multithreaded Logging Help

流过昼夜 提交于 2019-12-11 20:38:37
问题 I am working on a multithreaded logging for my engine. But I ma having troubles making it MT. The problem is, even if I am deep copying my logger object into a local variable I am going to have problems with the files. Because two threads are going to write to the same file at the same time which will build a mess. Here is my logger class: class Logger { public: typedef std::vector<LogListener *> ListenerList; private: ListenerList listeners; boost::mutex mutex; public: Logger(); ~Logger();

When installing gcc4.7 on 12.04, GCC doesn't switch from 4.6 to 4.7

a 夏天 提交于 2019-12-11 19:55:10
问题 I currently have the gcc4.7 and the gcc4.7-base, etc., packages installed but GCC seems to still be using 4.6 when I call gcc --version I could compile the source code if I really needed it now, but I plan on converting some old code to have fun with C++11. If anyone has any suggestions on how to switch from 4.6 to 4.7 do tell. I followed the guide from here : https://askubuntu.com/questions/113291/installing-gcc-4-7 Edit: Fixed the issue, updated link to /usr/bin/gcc-4.7 回答1: Try running the

Compiler error while using shared_ptr with a pointer to a pointer

情到浓时终转凉″ 提交于 2019-12-11 18:54:08
问题 I am new to using smart pointers in C++ and my current issue is that I am converting C code to C++ (C++11/14/17) and I am having some problems understanding using shared_ptr with a pointer to pointer. I have derived a toy example which I believe illustrates the problem Following is the header file #include <memory> using std::shared_ptr; struct DataNode { shared_ptr<DataNode> next; } ; struct ProxyNode { shared_ptr<DataNode> pointers[5]; } ; struct _test_ { ProxyNode** flane_pointers; }; And

Tiny crashing program

妖精的绣舞 提交于 2019-12-11 18:09:46
问题 The following program compiles with g++ but then crashes upon running: class someClass { public: int const mem; someClass(int arg):mem(arg){} }; int main() { int arg = 0; someClass ob(arg); float* sample; *sample = (float)1; return 0; } The following program does not crash: int main() { float* sample; *sample = (float)1; return 0; } 回答1: float* sample; *sample = (float)1; sample is never initialized to point to an object, so when you dereference it, your program crashes. You need to