undefined-reference

Undefined Reference issues using Semaphores

好久不见. 提交于 2019-12-30 02:07:04
问题 I am playing around with using Semaphores, but I keep encountering Undefined Reference warnings, thus causing my code not to work. I pulled example code from a text, but was having issues with some of their syntax, so I went to POSIX's semaphore tutorial and changed things around to their syntax and as a result am now getting these reference errors. I may simply be overlooking something, but I cannot find it. Errors: Producers_Consumers.c:52: warning: return type of ‘main’ is not ‘int’ /tmp

g++ undefined reference although symbol is present in *.so file

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 01:34:07
问题 I found a number of similar questions (e.g. this, that or this), but none of them helped me solve my problem. I have a *.so file (from the core of gnss-sdr) that, as indicated by: $nm libgnss_system_parameters_dyn.so | c++filt |grep Gps_Eph contains the symbol Gps_Ephemeris::Gps_Ephemeris() , which is supposed to be a constructor. I've written some minimal code: #include <iostream> #include <core/system_parameters/gps_ephemeris.h> int main(int argc,const char* argv[]) { Gps_Ephemeris ge;

undefined reference to sqrt (or other mathematical functions)

牧云@^-^@ 提交于 2019-12-27 10:46:34
问题 I have this simple code: max = (int) sqrt (number); and in the header I have: #include <math.h> But application still says undefined reference to sqrt . Do you see any problem here? It looks like everything should be okay. 回答1: You may find that you have to link with the math libraries on whatever system you're using, something like: gcc -o myprog myprog.c -L/path/to/libs -lm ^^^ - this bit here. Including headers lets a compiler know about function declarations but it does not necessarily

Undeclared identifiers with structs

对着背影说爱祢 提交于 2019-12-25 09:39:13
问题 struct FailedTransaction{ OrderNodePtr order; int failureID; struct FailedTransaction* next; struct FailedTransaction* tail; }; typedef struct FailedTransaction* FailedTransactionPtr; struct SuccessfulTransaction{ OrderNodePtr order; struct SuccessfulTransaction* next; struct SuccessfulTransaction* tail; }; typedef struct SuccessfulTransaction* SuccessfulTransactionPtr; struct FinalReport{ FailedTransactionPtr failedTransactions; SuccessfulTransactionPtr successfulTransactions; }; struct

What is an undefined reference/unresolved external symbol error and how do I fix it?

独自空忆成欢 提交于 2019-12-25 08:21:39
问题 What are undefined reference/unresolved external symbol errors? What are common causes and how to fix/prevent them? Feel free to edit/add your own. 回答1: Compiling a C++ program takes place in several steps, as specified by 2.2 (credits to Keith Thompson for the reference): The precedence among the syntax rules of translation is specified by the following phases [see footnote] . Physical source file characters are mapped, in an implementation-defined manner, to the basic source character set

make error) Undefined reference to std::__cxx11::basic_string

荒凉一梦 提交于 2019-12-24 18:31:35
问题 When I command make , I got errors like this: filter_block.cc:(.text+0x1c4): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)' I found some solutions for this error, like adding -D_GLIBCXX_USE_CXX11_ABI=0 , but I don't know how to add the command for make command. The Makefile is written as: .SUFFIXES: .c .cpp CC = g++ -fopenmp CFLAGS = -c -O2 -Wall -D_I386 -D_UNIX -fPIC -Wno-unused-result -std=c++11

Need help finding Undefined Symbols

元气小坏坏 提交于 2019-12-24 14:13:02
问题 I have a program that is compiling without warnings or errors but is hitting Undefined Reference problems. The program consists of three files. mybash.cc is a file I wrote. The two parser files were head start code given by a professor. The program is to display the working directory as a shell prompt and take in a command. The command is analyzed by parse and then information about it is printed by mybash. All of my Undefined Reference errors are not functions but a mess of characters. I am

Undefined reference to member function of template base class

烂漫一生 提交于 2019-12-24 00:52:59
问题 Consider following code: myclass.h : template <class T> struct S { void f(); }; struct MyClass : public S<int> { void g(); }; myclass.cpp : #include "myclass.h" #include <iostream> template <class T> void S<T>::f() { std::cout << "f()\n"; /* some code here that could not be in header */ } void MyClass::g() { std::cout << "g()\n"; } main.cpp : #include "myclass.h" int main() { MyClass m; m.g(); m.f(); // problem here } I've got linker error: undefined reference to `S::f()' Can I solve this

boost::signals2 undefined-reference when linking libraries together

淺唱寂寞╮ 提交于 2019-12-24 00:38:27
问题 I would like to link two libraries to my program. The first one, defines an object (of class ProducerObject ) which emits a signal. The second library defines two classes: a slave class which contains several instances of ProducerObject and a master class which can subscribe to the signals of the ProducerObject throught the slave class. The code of the first lib is: ProducerObject.hpp: #ifndef PRODUCEROBJECT_HPP_ #define PRODUCEROBJECT_HPP_ #include <boost/shared_ptr.hpp> #include <boost

with -lpthread, g++ compiler error, “undefined reference to ” semaphore calls such as `sem_open'

故事扮演 提交于 2019-12-23 13:21:34
问题 I am new to posix thread library, and I tried to compile a sample code from a tutorial with: g++ -lpthread agreement.cpp -o agreement however I was not able to compile the code and got the following error message: a3q2.cpp:(.text+0x7e): undefined reference to `sem_open' a3q2.cpp:(.text+0xab): undefined reference to `sem_wait' a3q2.cpp:(.text+0x290): undefined reference to `sem_post' a3q2.cpp:(.text+0x2af): undefined reference to `sem_close' a3q2.cpp:(.text+0x2bb): undefined reference to `sem