g++

Does static object in a template function have linkage?

眉间皱痕 提交于 2019-12-25 05:28:26
问题 This question refers to my previous question: clang does not compile my code, but g++ does. From my research, the issue at stake boils down to linkage, does the static variable data have linkage in the sample below (it compiles with g++-4.8.1 )? How come it has linkage (I would not otherwise be able to instantiate with a non-type template parameter)? template <int const* ptr> void foo() { } typedef void (*func_type)(); template <int = 0> void run_me() { static int data; func_type const f1 =

Undefined symbol std::__throw_bad_function_call

那年仲夏 提交于 2019-12-25 03:22:26
问题 I'm building C++ code in Eclipse CDT with g++ and I'm getting the following linker error: Undefined symbols for architecture x86_64: "std::__throw_bad_function_call()", referenced from: std::function<void (graphics::RenderingContext*)>::operator()(graphics::RenderingContext*) const in GameWindow.o I have std::function members in a class called GameWindow. Is there something I have to link to in order to get code using std::function to link properly? 回答1: Turns out my lib path wasn't set

Compiling c++ program with additional libraries using Linux g++

雨燕双飞 提交于 2019-12-25 03:07:49
问题 I have created a program using visual studio 2010, which is error free. However, when I try running it in Linux, using the g++ compiler, I run into some error regarding unknown functions, that should be known. I have the following files: main.cpp header.h header.cpp (all in the same folder) header2.h (which is in a different folder, /.../header2 various libraries, stored in yet another folder, /.../libs To compile the code I use the g++ compiler, writing the following in the terminal: g++

C++ Compilation Issue - Undefined symbols for architecture x86_64 - Mac Os X Mountain Lion

ぐ巨炮叔叔 提交于 2019-12-25 02:54:03
问题 I'm having a compilation issue which I'm unable to solve. I'm developing a cross platform C++ project coding on both Mac Os X 10.8 and Windows. The code compiles and run fine on Windows and on Mac Os X Leopard as well. Since Apple pushes the developers to stick to the latest platform for various reasons I'm forced to develop on Mountain Lion and I'm trying to get the project to work again. I compiled correctly all the libraries I needed (wxWidgets, etc) and I imported the project in the

unable to compile with library

限于喜欢 提交于 2019-12-25 02:15:34
问题 I would like to experiment with the OpenALPR SDK and have written a little test program. The problem is, I can't get it to compile properly and I'm not sure why. Here's the SDK documentation. My source file looks like: $ cat test.cpp #include <alpr.h> #include <iostream> std::string key = "MyKey"; int main (void) { alpr::Alpr openalpr("us", "/etc/openalpr/openalpr.conf", "/usr/share/openalpr/runtime_data/", key); // Make sure the library loaded before continuing. // For example, it could fail

Two mangled names demangling to the same function signature

感情迁移 提交于 2019-12-25 02:14:41
问题 I have a spidermonkey library that exports the following mangled symbol fora function JS_DefineProperty : _Z17JS_DefinePropertyP9JSContextP8JSObjectPKcN2JS5ValueEPFiS0_NS5_6HandleIS2_EENS7_I4jsidEENS5_13MutableHandleIS6_EEEPFiS0_S8_SA_iSC_Ej When I try to compile a file that uses this function, the external reference is compiled as: _Z17JS_DefinePropertyP9JSContextP8JSObjectPKcN2JS5ValueEPFiS0_NS5_6HandleIS2_EENS7_IlEENS5_13MutableHandleIS6_EEEPFiS0_S8_S9_iSB_Ej The end of the name is

Link a shared library with g++

旧巷老猫 提交于 2019-12-25 01:54:39
问题 I've got a cpp file a.cpp and a shared object libA.so it's gonna use under the same folder, however, when I tried to use g++ to link them together, it declares that it cannot find the library (I checked with ldd afterwards). This is the command I used g++ a.cpp -I . -L. -lA Any idea how this might be solved? Possible duplicates: building and linking a shared library 回答1: use g++ -o a a.cpp -I . -L. your-so-name.so 来源: https://stackoverflow.com/questions/47967646/link-a-shared-library-with-g

Equivalent of MSVC++ _wrename in linux g++?

拟墨画扇 提交于 2019-12-25 01:38:21
问题 Does anyone know if an equivalent of MSVC _wrename exist in linux g++ ? (equivalent of cstdio file rename function using const wchar_t* instead of const char* as parameter type for unicode use) Thanks ! 回答1: The point is that most filesystems other than NTFS store their filenames in byte -strings. There is usually no explicit notion of encoding, but the filenames have to be strings of non-zero bytes terminated by a zero. So on all such systems, filesystem functions just take char* arguments

Eclipse CDT displays semantic error, but builds successfully

青春壹個敷衍的年華 提交于 2019-12-25 00:17:47
问题 Before I update g++ from 4.6 to 4.7, my eclipse indigo CDT ran normally. After updating, it displays semantic errors, but builds and runs successfully. My code is that using my_type = int; Eclipse displays warning "syntax error" I updated g++ 4.7 as default compiler. 回答1: I fixed it by updating to eclipse juno . Before, I used eclipse helois what only supports C/C++ development tool 7.0 来源: https://stackoverflow.com/questions/15612673/eclipse-cdt-displays-semantic-error-but-builds

strncpy and strcat not working the way I think they would c++

扶醉桌前 提交于 2019-12-24 22:38:34
问题 I have an assignment to implement a string object ourselves, and am currently stuck when trying to concatenate two such strings. I figured I would go this route: allocate big enough space to hold insert beginning of holding string into new space up to index using strncpy(this part works) cat on the string I am inserting cat on the remainder of the holding string Implementation: #include <iostream> #include <cstring> using namespace std; int main(){ int index = 6;//insertion position char *