linker-errors

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

六眼飞鱼酱① 提交于 2019-12-13 03:59:41
问题 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

libxml2 on Cray not usable

岁酱吖の 提交于 2019-12-13 03:42:04
问题 I need to use libxml2 in a project that I want to compile on a Cray machine. In principle it is installed, there is a xml2-config program that gives me linker flags: $ xml2-config --libs -lxml2 -L/lib64 -lz -llzma -lm -ldl I have a very simple test program: $ cat test.c int main() { return 0; } Though in principle not needed, I can compile this with gcc test.c -lxml2 -L/lib64 -lz -llzma -lm -ldl just fine. However, with the Cray compiler it does not work: $ cc test.c -lxml2 -L/lib64 -lz

Same library included from two libraries

时光毁灭记忆、已成空白 提交于 2019-12-12 20:53:43
问题 I get error: ld: 24 duplicate symbols for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) because I have two libraries that both use GTMLogger.o . /Users/***/Library/Developer/Xcode/DerivedData/project-name/Build/Products/Debug-iphoneos/GoogleToolboxForMac/libGoogleToolboxForMac.a(GTMLogger.o) /Users/***/project-name/Libraries/Framework/Framework.framework/Framework(GTMLogger.o) One library is included as cocoapod and the other is included

Compiling error C++ - undefined references using PCRE library

若如初见. 提交于 2019-12-12 17:24:23
问题 I'm having problems compiling a code to test if the PCRE library is installed correctly. #include <string> #include <iostream> #include <pcre.h> int main (int argc, char *argv[]) { const char *error; int erroffset; pcre *re; int rc; int i; int ovector[100]; char *regex = "From:([^@]+)@([^\r]+)"; char str[] = "From:regular.expressions@example.com\r\n"\ "From:exddd@43434.com\r\n"\ "From:7853456@exgem.com\r\n"; re = pcre_compile (regex, /* the pattern */ PCRE_MULTILINE, &error, /* for error

Linker command failed with exit code 1 In Xcode

杀马特。学长 韩版系。学妹 提交于 2019-12-12 17:07:01
问题 I'm writing C program in Xcode, and I got this problem: ld: 1 duplicate symbol for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Any idea to solve it? Note: I've just update my OS to Mountain Lion yesterday. 回答1: A common error is to define a symbol in a header when you wanted to declare it: When you for instance declare a global variable and forget the extern or you define an inline function and forget the inline . In these cases the

Facebook symbols not found for i386 architecture

折月煮酒 提交于 2019-12-12 16:28:48
问题 I get the following error when trying to compile my project in xcode 4 (worked fine in xcode 3.x) Undefined symbols for architecture i386: "_OBJC_CLASS_$_FBSession", referenced from: objc-class-ref in View1Controls.o "_OBJC_CLASS_$_FBLoginDialog", referenced from: objc-class-ref in View1Controls.o "_OBJC_CLASS_$_FBRequest", referenced from: objc-class-ref in View1Controls.o "_OBJC_CLASS_$_FBStreamDialog", referenced from: objc-class-ref in View1Controls.o ld: symbol(s) not found for

Symbol lookup error (linux - c++)

て烟熏妆下的殇ゞ 提交于 2019-12-12 15:15:58
问题 i'm working on multi-agent system like Robocup soccerrSim2d On Gnu-linux . My distb is Ubuntu 11.10(kernel 3.2 - gcc 4.6 ) I installed librcsc from source . (it compiled and installed successfully) then I installed agent2d from src . (it compiled and installed successfully too !) But there is a problem with running the agent2d code : (when I run src/start.sh : ) this Error happens : ./src/sample_player: symbol lookup error: /usr/local/lib/librcsc_agent.so.7: undefined symbol:

Linux FreeBSD shared object problem

谁说胖子不能爱 提交于 2019-12-12 14:14:34
问题 I am trying to build an application for freebsd which links to a shared object "share.so" built on linux. I also have freebsd linux compatible libraries under /usr/compat/linux/lib. I am able to compile my application. But while linking to "share.so" I am getting bunch of errors as share.so(built on linux) needs to access libraries under "/usr/compat/linux/lib". Is there a way to tell share.so to look into compat linux directory instead of /usr/lib/ /usr/bin/ld: warning: libstdc++.so.6,

g++ Linking Error on Mac while compiling FFMPEG

跟風遠走 提交于 2019-12-12 13:24:09
问题 g++ on Snow Leopard is throwing linking errors on the following piece of code test.cpp #include <iostream> using namespace std; #include <libavcodec/avcodec.h> // required headers #include <libavformat/avformat.h> int main(int argc, char**argv) { av_register_all(); // offending library call return 0; } When I try to compile this using the following command g++ test.cpp -I/usr/local/include -L/usr/local/lib \ -lavcodec -lavformat -lavutil -lz -lm -o test I get the error Undefined symbols: "av

Linker error for variadic template

廉价感情. 提交于 2019-12-12 12:31:19
问题 I have a program with variadic templates and a helper function: #include <iostream> #include <string> using std::cout; template<typename... Ts> void fooImpl(char const *cp, Ts... args); template<typename... Ts> inline void foo(const std::string &s, Ts... args) { fooImpl(s.c_str(), args...); } void fooImpl(char const *cp) { // do something } template<typename T, typename... Ts> void fooImpl(char const *cp, T val, Ts... args) { char special{'@'}; while (*cp) { if (*cp == special) { // handle