标签: linker-errors

在Linux中链接Boost库

我正在尝试使用Boost的Asio构建一个项目,我遇到了一些麻烦.最初,我试图在没有任何额外库的情况下构建项目,因为所有内容都应该在头文件中.

我正在尝试构建的程序如下所示:

#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

int main()
{
    boost::asio::io_service io;
    boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));

    t.wait();

    std::cout << "Hello, world!" << std::endl;

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

可以发现这里在加速的网站.

所以,最初我只是:

-I /usr/include/boost_1_40_0
Run Code Online (Sandbox Code Playgroud)

这导致以下错误:

make -k all
Building target: HelloWorld
Invoking: GCC C++ Linker
g++  -o"HelloWorld"  ./main.o  
./main.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost_1_40_0/boost/system/error_code.hpp:205: undefined reference to `boost::system::get_system_category()'
/usr/include/boost_1_40_0/boost/system/error_code.hpp:206: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost_1_40_0/boost/system/error_code.hpp:211: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost_1_40_0/boost/system/error_code.hpp:212: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost_1_40_0/boost/system/error_code.hpp:213: undefined reference to `boost::system::get_system_category()'
./main.o: In function `boost::asio::error::get_system_category()':
/usr/include/boost_1_40_0/boost/asio/error.hpp:218: …
Run Code Online (Sandbox Code Playgroud)

linux boost linker-errors boost-asio deadline-timer

29
推荐指数
3
解决办法
4万
查看次数

29
推荐指数
6
解决办法
8万
查看次数

内联函数链接器错误

我正在尝试使用特定类的内联成员函数.例如,没有内联的函数声明和实现是这样的:

在头文件中:

int GetTplLSize();
Run Code Online (Sandbox Code Playgroud)

在.cpp文件中:

int NeedleUSsim::GetTplLSize()
{
    return sampleDim[1];
}
Run Code Online (Sandbox Code Playgroud)

出于某种原因,如果我将"inline"关键字放在实现和声明中的任何一个中,以及两个地方,我都会收到链接器错误,如下所示:

 Creating library C:\DOCUME~1\STANLEY\LOCALS~1\TEMP\MEX_HN~1\templib.x and object C:\DOCUME~1\STANLEY\LOCALS~1\TEMP\MEX_HN~1\templib.exp 
mexfunction.obj : error LNK2019: unresolved external symbol "public: int __thiscall NeedleUSsim::GetTplLSize(void)" (?GetTplLSize@NeedleUSsim@@QAEHXZ) referenced in function _mexFunction 
mexfunction.mexw32 : fatal error LNK1120: 1 unresolved externals 

  C:\PROGRA~1\MATLAB\R2008B\BIN\MEX.PL: Error: Link of 'mexfunction.mexw32' failed. 

为了摆脱这个错误需要做什么(即在制作这些内联成员函数方面我做错了什么)?

c++ inline linker-errors

28
推荐指数
3
解决办法
2万
查看次数

内联函数"未定义符号"错误

我想写一个内联函数,但是我收到一个错误.我该如何解决?

错误信息:

Undefined symbols for architecture i386:
  "_XYInRect", referenced from:
      -[BeginAnimation ccTouchesEnded:withEvent:] in BeginAnimation.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

码:

CGPoint location = CGPointMake(60, 350);

if (XYInRect(location, 53, 338, 263, 369)) {

}

inline BOOL XYInRect(CGPoint location, float MixX, float MixY, float MaxX ,float MaxY){
    if (location.x >MixX && location.y >MixY && location.x <MaxX && location.y <MaxY) {
        return YES;
    } else {
        return …
Run Code Online (Sandbox Code Playgroud)

c compiler-errors inline objective-c linker-errors

24
推荐指数
1
解决办法
5890
查看次数

APPLE MACH-O LINKED ERROR添加AFNetworking后

只是将AFNetworking添加到我的项目中,在B&R之后我得到了这样的错误:

Undefined symbols for architecture i386:
"_SecCertificateCopyData", referenced from:
  -[AFURLConnectionOperation connection:willSendRequestForAuthenticationChallenge:] in       AFURLConnectionOperation.o
"_SecCertificateCreateWithData", referenced from:
  ___44+[AFURLConnectionOperation pinnedPublicKeys]_block_invoke in  AFURLConnectionOperation.o
"_SecPolicyCreateBasicX509", referenced from:
  ___44+[AFURLConnectionOperation pinnedPublicKeys]_block_invoke in AFURLConnectionOperation.o
  -[AFURLConnectionOperation connection:willSendRequestForAuthenticationChallenge:] in AFURLConnectionOperation.o
"_SecTrustCopyPublicKey", referenced from:
  ___44+[AFURLConnectionOperation pinnedPublicKeys]_block_invoke in AFURLConnectionOperation.o
  -[AFURLConnectionOperation connection:willSendRequestForAuthenticationChallenge:] in AFURLConnectionOperation.o
"_SecTrustCreateWithCertificates", referenced from:
  ___44+[AFURLConnectionOperation pinnedPublicKeys]_block_invoke in AFURLConnectionOperation.o
  -[AFURLConnectionOperation connection:willSendRequestForAuthenticationChallenge:] in AFURLConnectionOperation.o
"_SecTrustEvaluate", referenced from:
  ___44+[AFURLConnectionOperation pinnedPublicKeys]_block_invoke in AFURLConnectionOperation.o
  -[AFURLConnectionOperation connection:willSendRequestForAuthenticationChallenge:] in AFURLConnectionOperation.o
"_SecTrustGetCertificateAtIndex", referenced from:
  -[AFURLConnectionOperation connection:willSendRequestForAuthenticationChallenge:] in AFURLConnectionOperation.o
"_SecTrustGetCertificateCount", referenced from:
  -[AFURLConnectionOperation connection:willSendRequestForAuthenticationChallenge:] in AFURLConnectionOperation.o
ld: symbol(s) …
Run Code Online (Sandbox Code Playgroud)

mach-o linker-errors ios afnetworking

24
推荐指数
2
解决办法
7652
查看次数

c)出错和链接问题:i386:x86-64输入文件架构,与i386输出不兼容

当我在终端输入"make"时,我输出错误信息!!

gcc test1.o dispatchQueue.o -o test1 -pthread
/usr/bin/ld: i386:x86-64 architecture of input file `test1.o' is incompatible with i386     output
/usr/bin/ld: final link failed: Invalid operation
collect2: ld returned 1 exit status
make: *** [test1] Error 1
Run Code Online (Sandbox Code Playgroud)

有没有人可以解释为什么以及如何解决它?:(

我附加makefile以防万一

# Comment out the targets you don't want.

# Runs all of the tests.
all: test1 test2 test3 test4 test5 testFor
    ./test1
    ./test2
    ./test3
    ./test4
    ./test5
    ./testFor

test1: test1.o dispatchQueue.o
    gcc test1.o dispatchQueue.o -o test1 -pthread

test1.o: test1.c
    gcc -c test1.c

test2: …
Run Code Online (Sandbox Code Playgroud)

c compiler-errors makefile linker-errors incompatibletypeerror

23
推荐指数
1
解决办法
7万
查看次数

Apple LLVM 4.1的STD链接器错误

我在C++中有一个大型静态库,其中有一些Objective-C最初是为iOS(armv7)构建的.

我构建了一个OS X(64位Intel x86_64)版本,但是当我尝试在OS X应用程序项目中使用它(针对Lion 10.7)时,出现了数十个链接器错误,其中大部分都是关于标准库的符号.

我知道如何解决"我的"链接器问题,但下面复制的STD问题让我烦恼.

"std::basic_filebuf<char, std::char_traits<char> >::is_open() const"
"std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const"
"std::basic_ios<char, std::char_traits<char> >::widen(char) const"
"std::istream& std::istream::_M_extract<double>(double&)"
"std::ostream::put(char)"
"std::ostream::flush()"
"std::ostream& std::ostream::_M_insert<void const*>(void const*)"
"std::ostream& std::ostream::_M_insert<bool>(bool)"
"std::ostream& std::ostream::_M_insert<double>(double)"
"std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)"
"std::ostream::operator<<(int)"
"std::ostream::operator<<(short)"
"std::string::_Rep::_M_destroy(std::allocator<char> const&)"
"std::string::_Rep::_S_terminal"
"std::string::_Rep::_S_empty_rep_storage"
"std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&)"
"std::string::append(char const*, unsigned long)"
"std::string::append(std::string const&)"
"std::string::assign(std::string const&)"
"std::string::reserve(unsigned long)"
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)"
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)"
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()"
"std::basic_ofstream<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode)"
"std::basic_ofstream<char, …
Run Code Online (Sandbox Code Playgroud)

c++ macos xcode std linker-errors

23
推荐指数
3
解决办法
3万
查看次数

Xcode给Apple Mach-O链接器错误

我刚编译了一个项目,Xcode返回这两个错误,这些错误似乎不是我代码的错.我该如何解决?

Undefined symbols for architecture i386:
  "_vImageBoxConvolve_ARGB8888", referenced from:
      -[UIImage(Blur) boxblurImageWithBlur:] in UIImage+Blur.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

mach-o objective-c linker-errors undefined-symbol ios

23
推荐指数
2
解决办法
5万
查看次数

部署目标为7.0时,体系结构错误的未定义符号

我在我的原生iOS应用程序(一堆.a库)中使用第三方框架.我的应用程序是使用XCode 5 base SDK 7.0开发的.

当部署目标为6.1(库和头搜索路径良好)时,库可以编译和链接.但是,当我将部署目标更改为7.0时,我收到以下链接器错误:

Undefined symbols for architecture i386:
  "std::string::find_last_of(char const*, unsigned long) const", referenced from:
      GetExecutionDir(ECTemplateString<char>&, char*, bool) in myLibrary.a(moPlatForm.o)
  "std::string::find(char const*, unsigned long) const", referenced from:
      ParseLog(std::string const&, unsigned int&, CmoDateTime&, int&, std::string&) in myLibrary.a(AppLog.o)
  "std::string::size() const", referenced from:
      mo::CmoParam::WriteToStream(void*, mo::STREAM_STATE*) in myLibrary.a(moParams.o)
  "std::string::c_str() const", referenced from:
      GetExecutionDir(ECTemplateString<char>&, char*, bool) in myLibrary.a(moPlatForm.o)
      CMocaFileTransfer::UpdateParamsForGetTraceFiles(mo::CmoParamList&, long) in myLibrary.a(RobieFileTransfer.o)
      CMocaFileTransfer::AddTraceFileForUpload(std::string const&, std::string const&) in myLibrary.a(RobieFileTransfer.o)
      CMocaFileTransfer::CreateParamsForSendTraceFiles(mo::CmoObject&) in myLibrary.a(RobieFileTransfer.o)
      mo::CmoParam::WriteToStream(void*, mo::STREAM_STATE*) in myLibrary.a(moParams.o)
      ParseLog(std::string const&, unsigned int&, CmoDateTime&, int&, std::string&) …
Run Code Online (Sandbox Code Playgroud)

iphone xcode linker-errors ios ios7

23
推荐指数
3
解决办法
1万
查看次数

ld:在 macOS 中构建 rust 时未找到 -lpq 的库

当我使用以下命令在 macOS 中使用 apple sillicon 构建 rust 项目时:

CARGO_HTTP_MULTIPLEXING=false cargo build
Run Code Online (Sandbox Code Playgroud)

显示这样的错误:

  = note: ld: library not found for -lpq
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

我已经尝试安装

brew install libpq
brew link --force libpq
Run Code Online (Sandbox Code Playgroud)

仍然没有解决这个问题,我应该怎么做才能解决这个问题?是不是 PostgreSQL 库现在不​​支持 Apple Silicon(Apple M1 Pro)?这是我的项目依赖项:

[package]
name = "reddwarf_dict"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rocket = { version = "0.5.0-rc.1", features = ["json"] }
serde …
Run Code Online (Sandbox Code Playgroud)

linker-errors rust

22
推荐指数
4
解决办法
8515
查看次数