有人对此有所了解吗?链接器错误远远超出了我的驾驶室,特别是像这样的.
我还应该包含更多信息吗?
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) 我正在看:
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"目录,我可以删除没有任何问题...我不明白发生了什么,但我现在可以运行我的可执行文件...
我正在研究一个非常古老的源代码(用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标志已经存在.
我只想知道要尝试的事情.一切都很受欢迎.这让我疯了.
我正在使用类似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
你们觉得呢?实际上,什么时候出现“符号查找错误”?
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)并找到它应该存在的图像/库(在本例中为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)


我正忙着编写一个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.o和QPBO.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) 我试图让OpenSSL工作,但似乎链接有问题.这是我做的:
#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)
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)
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' …
我正在制作一个需要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错误?
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) 我如何特别地使用-v调用来查看有关cmake链接器错误的详细信息?我发现了两个有关使用此选项的问题,但是一个问题是针对Xcode构建的,另一个问题是针对NDK构建的。他们在这里:
我在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)