标签: linker-errors

仅限发布版本的大量链接器问题

有人对此有所了解吗?链接器错误远远超出了我的驾驶室,特别是像这样的.

我还应该包含更多信息吗?

1>Linking...
1>freeglut_static.lib(freeglut_window.obj) : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __heap_alloc already defined in LIBCMT.lib(malloc.obj)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __recalloc already defined in LIBCMT.lib(recalloc.obj)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __msize already defined in LIBCMT.lib(msize.obj)
1>LIBCMTD.lib(malloc.obj) : error LNK2005: _V6_HeapAlloc already defined in LIBCMT.lib(malloc.obj)
1>LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in LIBCMT.lib(dbghook.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_pHeaderDefer already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: __get_sbh_threshold already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: …
Run Code Online (Sandbox Code Playgroud)

c++ opengl linker glut linker-errors

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

Mac OSX 10.6.7上的链接错误

我正在看:

ld: in objs/AttributeValueTest.o, can't link with a main executable for architecture x86_64
Run Code Online (Sandbox Code Playgroud)

构建一个只有1 .h和1 .cpp文件的非常简单的程序时.

编译行是:

g++ -g -I./ -I/usr/local/include -o objs/AttributeValueTest.o tp_datastruct/tests/AttributeValueTest.cpp -L/usr/local/lib -lavrocpp -lcppunit -lm 
g++ -g -I./ -I/usr/local/include -o AttributeValueTest objs/AttributeValueTest.o -L/usr/local/lib -lavrocpp -lcppunit -lm 
Run Code Online (Sandbox Code Playgroud)

我试图指定-arch x86_64,-arch i386和-m32,但没有任何效果(我有其他错误,它抱怨libcppunit的格式不正确).

任何想法/指针/建议?

谢谢!


很奇怪.我做了一些挖掘,并看到了某个地方,AttributeValueTest.o可能已经是一个可执行文件.我在AttributeValueTest.o上做了一个"文件",果然,它是一个随时可用的可执行文件.我修改了我的makefile,将.o重命名为AttributeValueTest,我很乐意运行它.此外,可执行文件附带一个".dSYM"目录,我可以删除没有任何问题...我不明白发生了什么,但我现在可以运行我的可执行文件...

macos linker linker-errors

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

从lua 4.0.1升级到5.1.4时链接错误

我正在研究一个非常古老的源代码(用Red Hat编译).之前它有lua-4.0.1所以我只编译了最新的lua(lua-5.1.4)并将它安装在与旧的相同的目录中.实现不是很大,所以除了一些函数名称之外没什么可改变的,我必须包含"lauxlib.h"才能让它编译.它编译没有任何问题,但它给出了这些链接错误.

/usr/local/lib/liblua.a(loadlib.o): In function `ll_load':
loadlib.o(.text+0x19): undefined reference to `dlopen'
loadlib.o(.text+0x2a): undefined reference to `dlerror'
/usr/local/lib/liblua.a(loadlib.o): In function `ll_sym':
loadlib.o(.text+0x52): undefined reference to `dlsym'
loadlib.o(.text+0x63): undefined reference to `dlerror'
/usr/local/lib/liblua.a(loadlib.o): In function `ll_unloadlib':
loadlib.o(.text+0x8): undefined reference to `dlclose'
Run Code Online (Sandbox Code Playgroud)

基本上所有路径都是正确的,但我使用与旧编译器相同的标志,我根本没有更改makefile.

-static -lpthread -lnsl -lutil -ldl -lmysqlclient -llua -llualib -lz -lcppunit
Run Code Online (Sandbox Code Playgroud)

ldl标志已经存在.

我只想知道要尝试的事情.一切都很受欢迎.这让我疯了.

c++ lua linker-errors

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

符号查找错误(Linux-C ++)

我正在使用类似Robocup soccerrSim2dGnu-linux的多代理系统。我的distb是Ubuntu 11.10(内核3.2-gcc 4.6)

我从源代码安装了librcsc。(它已成功编译并安装)

然后我从src 安装了agent2d。(它也成功编译并安装!)

但与运行agent2d代码中的问题:(当我运行src/start.sh:)

发生此错误:

./src/sample_player:符号查找错误:/usr/local/lib/librcsc_agent.so.7:未定义的符号:_ZN4rcsc9UDPSocketC1EPKci

你们觉得呢?实际上,什么时候出现“符号查找错误”?

c++ linux linker-errors

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

iOS未定义的体系结构i386符号:"_ kUTTypeImage"

Undefined symbols for architecture i386:
  "_kUTTypeImage", referenced from:
      -[ViewController receiveNotification:] in ViewController.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)

我正在向我的应用程序添加一个UIImagePickerController,当我去编译时,我得到了上述错误.我在SO上找到了一个解决方案:

找不到符号:kUTTypeImage

查找符号(kUTTypeImage)并找到它应该存在的图像/库(在本例中为MobileCoreServices.framework).然后将您的二进制文件与该框架链接

问题是,我不确定如何实现它.如何查找符号然后将其链接到框架?

应该注意到我已经导入了MobileCoreServices框架.这是相关的代码:

if ([UIImagePickerController isSourceTypeAvailable:
                 UIImagePickerControllerSourceTypeCamera]) {

                UIImagePickerController* myCamera = [[UIImagePickerController alloc] init];
                myCamera.delegate = self;
                myCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
                myCamera.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage, nil];
                myCamera.allowsEditing = NO;
                [self presentModalViewController:myCamera animated:YES];

            }
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

在此输入图像描述

xcode linker-errors uiimagepickercontroller ios

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

链接MATLAB Mex库中的错误

我正忙着编写一个MATLAB Mex库 - 特别是来自这个网站的'Correlation Clustering Optimization'代码.

我想在OSX机器上编译,并使用提供的mexall函数.这将运行以下行:

mex -O -largeArrayDims CXXFLAGS="\$CXXFLAGS -Wno-write-strings" QPBO.cpp QPBO_extra.cpp QPBO_maxflow.cpp QPBO_wrapper_mex.cpp QPBO_postprocessing.cpp -output QPBO_wrapper_mex
Run Code Online (Sandbox Code Playgroud)

链接时将错误发生在以下输出到MATLAB命令行:

ld: duplicate symbol QPBO<int>::GetMaxEdgeNum()    in QPBO_extra.o and QPBO.o
collect2: ld returned 1 exit status

    mex: link of ' "QPBO_wrapper_mex.mexmaci64"' failed.
Run Code Online (Sandbox Code Playgroud)

从此判断,功能GetMaxEdgeNum出现在QPBO_extra.oQPBO.o.但是,它实际上只在头文件中定义QPBO.h.因此,我怀疑包含它的两个源文件都将其作为符号包含在其目标文件中,从而导致链接时出现问题.

(更多信息:每个源文件还包含文件#include "instances.inc"末端的文件.instances.inc显然似乎包含模板化的一些特定实例QPBO.)

我在这里犯了一个明显的错误吗?我该怎么做才能增加编译代码的机会?

编辑

这是有问题的GetMaxEdgeNum函数的定义QPBO.h:

template <typename REAL> 
    inline int QPBO<REAL>::GetMaxEdgeNum() 
{
    return (int)(arc_max[0]-arcs[0])/2;
} …
Run Code Online (Sandbox Code Playgroud)

c++ macos matlab linker-errors mex

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

未定义的引用`ERR_load_crypto_strings'

我试图让OpenSSL工作,但似乎链接有问题.这是我做的:

  1. 我从https://www.openssl.org/source/下载了OpenSSL for Linux.我尝试了0.9.8zc,1.0.0o和1.0.1j版本,都具有相同的结果.
  2. 我使用./config,make和sudo make install安装了每个OpenSSL版本.
  3. 出于调试目的,我去了/ usr/lib/ssl并使用了sudo chmod -R 777*来删除任何可能导致错误的限制.
  4. 我创建了以下程序:

main.c中:

#include <errno.h>
#include <malloc.h>
#include <resolv.h>
#include <openssl/bio.h>
#include <openssl/ssl.h>
int main(void) {
    SSL_load_error_strings();
    return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
  1. 我在与.c文件相同的目录中创建了以下makefile:

生成文件:

all: main.o
    cc -o main main.o -L/usr/local/ssl/lib/ -lcrypto -lssl
main.o: main.c
    cc -c -Wall main.c -I/usr/local/ssl/include/ -o main.o
Run Code Online (Sandbox Code Playgroud)
  1. 当我运行makefile时,我收到以下错误:

cc -o main main.o -L/usr/local/ssl/lib/-lcrypto -lssl /usr/local/ssl/lib//libssl.a(ssl_err2.o):在函数SSL_load_error_strings': ssl_err2.c:(.text+0x4): undefined reference toERR_load_crypto_strings'/ usr/local/ssl/lib // libssl.a(ssl_err.o):在函数ERR_load_SSL_strings': ssl_err.c:(.text+0xc): undefined reference toERR_func_error_string'sssl_err.c :(.text + 0x28)中:未定义引用ERR_load_strings' …

linux openssl makefile linker-errors

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

将SQLite链接到DLL的LNK2019错误(未解析的外部符号)

我正在制作一个需要SQLite的C++ DLL.

我已经集成了SQLite头文件(sqlite3.h)并在外部依赖项中添加了库.我没有语法错误,但是当我尝试编译项目时,我得到以下LNK2019("未解析的外部符号[XYZ]从函数引用...")错误:

error LNK2019: symbole externe non résolu sqlite3_close référencé dans la fonction "void __cdecl DisonnectDB(bool,struct sqlite3 *)" (?DisonnectDB@@YAX_NPEAUsqlite3@@@Z) C:\Users\Akash\Downloads\Learn Curve\Freelance\Travis\sana\Sana\Sana.obj Sana

error LNK2019: symbole externe non résolu sqlite3_column_text référencé dans la fonction "wchar_t const * __cdecl getTableData(struct sqlite3 *)" (?getTableData@@YAPEB_WPEAUsqlite3@@@Z) C:\Users\Akash\Downloads\Learn Curve\Freelance\Travis\sana\Sana\Sana.obj Sana

我试图在测试控制台应用程序中执行相同的过程,并且我能够编译没有错误,因此我确信问题不在于SQLite库或头文件的可见性.

关于Stack Overflow的其他问题并不特定于DLL如何与静态库交互.

是否有必要在DLL中使用SQLite库而不是在控制台应用程序中使用?
如何修复编译时LNK2019错误?

c++ sqlite dll linker-errors

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

SFML的链接器错误

g++ -lsfml-window -lsfml-graphics -lsfml-system main.cpp在示例SFML代码上运行,在Ubuntu,SFML 2.2和g ++ 4.8.2上运行时,出现一系列错误。我尝试从包管理器(libsfml-dev)重新安装SFML,但没有任何效果。

SFML代码示例:

#include <SFML/Graphics.hpp>
#include <string>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
    sf::Event event;
    while (window.pollEvent(event))
    {
        if (event.type == sf::Event::Closed)
            window.close();
    }

    window.clear();
    window.draw(shape);
    window.display();
    }

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

错误信息:

/tmp/ccVG6GjG.o: In function `main':
main.cpp:(.text+0xf7): undefined reference to `sf::String::String(char const*, std::locale const&)'
main.cpp:(.text+0x115): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
main.cpp:(.text+0x148): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, …
Run Code Online (Sandbox Code Playgroud)

c++ linker-errors sfml

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

如何使用-v调用查看有关cmake链接器错误(未定义符号)的详细信息?

我如何特别地使用-v调用来查看有关cmake链接器错误的详细信息?我发现了两个有关使用此选项的问题,但是一个问题是针对Xcode构建的,另一个问题是针对NDK构建的。他们在这里:

使用-v查看调用?

如何使用cmake -v调用来帮助查找链接器错误

我在OSX Mojave上。我正在使用标准的cmakelists.txt方法,错误是这样的:

Undefined symbols for architecture x86_64:
   "Image::createImage(int, int, int)", referenced from:
       _main in tutorial.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

SO问题中的一条注释显示了我要执行的操作:

...you could use -v to see the linker invocation to see what's going wrong. It would show you this link line:

"/usr/bin/ld" -demangle -dynamic -arch x86_64 
    -macosx_version_min 10.6.8 -o a.out -lcrt1.10.6.o
    /var/folders/zl/zlZcj24WHvenScwjPFFFQE+++TI/-Tmp-/cc-hdOL8Z.o
    -lSystem /Developer/usr/bin/../lib/clang/3.0/lib/darwin/libclang_rt.osx.a
Run Code Online (Sandbox Code Playgroud)

(我是cmake菜鸟新手)我已经在cmakelists.txt中尝试了以下所有方法,但它们均无效:

add_link_options(-v)
add_link_options("-v")
target_link_options(myexec PUBLIC …
Run Code Online (Sandbox Code Playgroud)

c++ macos cmake linker-errors undefined-symbol

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