linker

Undefined reference to `std::chrono::_V2::system_clock::now()' when linking with gfortran

坚强是说给别人听的谎言 提交于 2019-12-24 08:59:33
问题 I am trying to create an user defined block in INSEL which requires C++ to program and I link it using gfortran. I have the following code in my program // Setting seed for random number generators unsigned seed = static_cast<int> (std::chrono::system_clock::now().time_since_epoch().count()); to set as a seed to my random number generator. When i compile it using g++ (gcc v.5.1.0) it shows no error or warning. My compiling command is g++ -O0 -Wall -c -g3 -std=c++14 -fmessage-length=0 $

Including header file with global variable

萝らか妹 提交于 2019-12-24 08:49:30
问题 I need to include a header file that contains some global variables (not mine so I cannot change it). How do I do this so that the variables within the included file are considered 'extern' in all but one case? 回答1: You cannot. Copy the header and add extern yourself. 回答2: If the variables are only declared in the header, but aren't assigned a value, then you might be able to do this, depending on the compiler. GCC, for example, has the -fno-common flag to control this behavior. 来源: https:/

C++ linker issues

拥有回忆 提交于 2019-12-24 08:48:00
问题 I have this: a.cpp int localfunction () { return 1; } int local_symbol = localfunction(); b.cpp void thirdfunction () {}; main.cpp void main () { thirdfunction (); } When I compile this in a main executable everything works (even with optimizations), and the localfunction is executed at startup even if I don't call it directly. Now, in Visual C++ and GCC , I put a.cpp and b.cpp in a static library (.lib). localfunction is no more executed/defined. From what I understand the symbol is detected

C++ Why does this specific situation cause a symbol linking error?

给你一囗甜甜゛ 提交于 2019-12-24 08:26:52
问题 I'm working on an application where there's a 'core' and multiple plugins. I'm using Qt on Linux, and I use Qt's plugin loader system. Plugins are created as shared object files (*.so) and loaded dynamically. If I link to a library with a plugin, and that library links to additional libraries, I often get an 'undefined symbol' error from the application. To get around it, I need to link the plugin to the additional libraries as well... Plugin links to LibA LibA links to LibB, LibC LibA is

CUDA - linking errors with convolution example

馋奶兔 提交于 2019-12-24 08:25:33
问题 I'm trying to compile the following code by Joe Stam (convolutionapproaches, project with vs2005, I am using VS2010 but compiling with 9.0 engine) 1>ConvolutionCudaFunctions.obj : error LNK2019: unresolved external symbol _cudaEventDestroy@4 referenced in function "float _cdecl NaiveGlobalConvolution(unsigned char *,unsigned char *,unsigned int,unsigned int,unsigned int,int,int)" (?NaiveGlobalConvolution@@YAMPAE0IIIHH@Z) 1>main.obj : error LNK2001: unresolved external symbol _cudaEventDestroy

Limitations of Linker with Codebase using Large Lookup Tables in Visual Studio 2010

痴心易碎 提交于 2019-12-24 07:57:18
问题 In my work, we have a variety of large tables storing data used for a set of multidimensional nonparametric models. Each table is a float array with a size of typically 200,000 to 5,000,000 elements. Today, I was going about a normally trivial update to this codebase, updating a set of the lookup tables, when I found the compiling and linking of the project was resulting in a Microsoft Incremental Linker has Stopped Working , something I had not seen before. Note that the tables I was

Unable to link against BFD [duplicate]

假装没事ソ 提交于 2019-12-24 07:26:32
问题 This question already has answers here : Trying to include a library, but keep getting 'undefined reference to' messages (3 answers) Closed 5 years ago . I am trying to include this file in my project: http://cairo.sourcearchive.com/documentation/1.9.4/backtrace-symbols_8c-source.html But it requires linking against BFD. I have both binutils and binutils-devel installed. I have tried linking with -lbfd as well as directly to /usr/lib64/libbfd.so and /usr/lib64/libbfd.a (which both do exist).

static ints, compilation units and the ternary operator

和自甴很熟 提交于 2019-12-24 06:58:16
问题 // SomeCls.h class SomeCls { static const int PERIOD_ALARM_NORMAL = 5; static const int PERIOD_ALARM_THRESH = 1; void method() { bool b = true; const int d = b ? PERIOD_ALARM_THRESH : PERIOD_ALARM_NORMAL; } } obj; It is going to build ok. Now take out the method() implementation and place it in a cpp file: //SomeCls.cpp #include "SomeCls.h" void SomeCls::method() { bool b = true; const int d = b ? PERIOD_ALARM_THRESH : PERIOD_ALARM_NORMAL; } Why does mr. linker say undefined reference to

gcc or g++ path search order on default directories when linking libraries

前提是你 提交于 2019-12-24 06:34:06
问题 I've seen this article and learned that: Directories specified on the command line with -L option are searched before the default directories. The directories specified in -L are searched in the order in which they are specified on the command line. The question is: Is there an search order for the default directories? For example, if I run this command: $ gcc -Xlinker --verbose 2>/dev/null | grep SEARCH | sed 's/SEARCH_DIR("=\?\([^"]\+\)"); */\1\n/g' | grep -vE '^$' (command copied from this

Setting path to shared library inside a makefile for compile

…衆ロ難τιáo~ 提交于 2019-12-24 04:52:10
问题 I want to compile a program using makefile which is linked against the zlib shared libraries which it is different from the one installed on my system. But I don't want them to be permanently added to the library pool of my system. The path of custom zlib is /usr/work/libxlsxwriter-master/zlib-1.2.8 I have tried to use something like: ZLIBDIR=/usr/work/libxlsxwriter-master/zlib-1.2.8 # The static library. $(LIBXLSXWRITER_A) : $(OBJS) export LD_LIBRARY_PATH=$(ZLIBDIR):$(DEPENDENCIES); \ $(Q)$