我是 Objective-C 的新手,当我从 xcode 中的 sqlite3 调用添加时收到此错误。有人知道我可以做些什么来修复这个错误吗?
Undefined symbols for architecture x86_64:
"_sqlite3_close", referenced from:
-[InAppUtils get:] in libInAppUtils.a(InAppUtils.o)
"_sqlite3_exec", referenced from:
-[InAppUtils get:] in libInAppUtils.a(InAppUtils.o)
"_sqlite3_open", referenced from:
-[InAppUtils get:] in libInAppUtils.a(InAppUtils.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)
我尝试添加该libsqlite3.dylib库,但在我的系统上找不到它。是必须的吗?如果是这样,我该如何找到它?
我正在编译一个包含来自 pthread 库的互斥信号量的程序,但是当我使用 -lpthread 标志进行编译时,我收到了未定义的引用错误。
gcc -lpthread prodcon.c
/tmp/ccESOlOn.o: In function `producer':
prodcon.c:(.text+0x2e): undefined reference to `pthead_mutex_lock'
prodcon.c:(.text+0xd6): undefined reference to `pthead_mutex_unlock'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
互斥锁的语法如下:
pthread_mutex_t mutex1;
Run Code Online (Sandbox Code Playgroud)
是一个全局声明,以便它可以被多个线程使用。在函数中,我像这样调用互斥体:
pthead_mutex_lock(&mutex1);
pthead_mutex_unlock(&mutex1);
Run Code Online (Sandbox Code Playgroud)
但我收到编译器错误,我也尝试使用 -pthread 标志进行编译
gcc -pthread prodcon.c
/tmp/cc6wiQPR.o: In function `producer':
prodcon.c:(.text+0x2e): undefined reference to `pthead_mutex_lock'
prodcon.c:(.text+0xd6): undefined reference to `pthead_mutex_unlock'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我已经寻找答案,但我不知所措,并且希望能够帮助您弄清楚当我链接到包含互斥锁的库时为什么它有未定义的引用。
我正在运行这个命令——
/usr/bin/c++ CMakeFiles/XYZ.dir/test/XYZ.cpp.o CMakeFiles/XYZ.dir/test/TempDir.cpp.o
-o XYZ libXYZMaster.so -lboost_filesystem -lboost_system
/usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so -lboost_random
-lboost_iostreams -lboost_thread -ldw -lunwind
-Wl,-rpath,/home/user885/untitled/build
Run Code Online (Sandbox Code Playgroud)
但我收到这个链接器错误 -
libXYZMaster.so: undefined reference to `_Ux86_64_step'
libXYZMaster.so: undefined reference to `_Ux86_64_init_local'
libXYZMaster.so: undefined reference to `_Ux86_64_get_proc_name'
libXYZMaster.so: undefined reference to `_Ux86_64_get_reg'
Run Code Online (Sandbox Code Playgroud)
当我执行 nm -DI 时,确实看到了定义的符号 -
$ nm -D /usr/lib/x86_64-linux-gnu/libunwind.so | grep -P "_step|init_local|get_proc_name|get_reg"
00000000000031d0 T _ULx86_64_get_proc_name
0000000000003370 T _ULx86_64_get_reg
0000000000004510 T _ULx86_64_init_local
0000000000004d20 T _ULx86_64_step
Run Code Online (Sandbox Code Playgroud)
另外,libXYZMaster.so 的 ldd 表明 libunwind 已链接——
linux-vdso.so.1 => (0x00007ffd58f4a000)
libdw.so.1 => /usr/lib/x86_64-linux-gnu/libdw.so.1 (0x00007ff614bac000)
libunwind.so.8 => /usr/lib/x86_64-linux-gnu/libunwind.so.8 (0x00007ff614991000) …Run Code Online (Sandbox Code Playgroud) 我尝试使用多种方法让它发挥作用,无论我不断得到什么:
/usr/local/include/vulkan/vulkan.hpp:2453: undefined reference to `vkCreateDebugUtilsMessengerEXT'
/usr/local/include/vulkan/vulkan.hpp:2548: undefined reference to `vkDestroyDebugUtilsMessengerEXT'
Run Code Online (Sandbox Code Playgroud)
这是我目前拥有的(希望这是足够的代码来诊断问题)
// destroy and create funcs
PFN_vkCreateDebugUtilsMessengerEXT pfnVkCreateDebugUtilsMessengerEXT;
PFN_vkDestroyDebugUtilsMessengerEXT pfnVkDestroyDebugUtilsMessengerEXT;
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pMessenger)
{
return pfnVkCreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger);
}
VKAPI_ATTR void VKAPI_CALL vkDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, VkAllocationCallbacks const * pAllocator)
{
return pfnVkDestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator);
}
Run Code Online (Sandbox Code Playgroud)
// instance creation stuff here ...
createUniqueInstance(...);
//
// init and setup debug utils messenger
pfnVkCreateDebugUtilsMessengerEXT = reinterpret_cast<PFN_vkCreateDebugUtilsMessengerEXT>(
instance->getProcAddr("vkCreateDebugUtilsMessengerEXT"));
if (!pfnVkCreateDebugUtilsMessengerEXT) { …Run Code Online (Sandbox Code Playgroud) 如何将模板定义转换为单独的头文件?
我的代码在包含在单个main.cpp中时编译.
maip.cpp
#include <windows.h>
#include <tchar.h>
template<class T1, class T2>
class Base {
public:
virtual ~Base() {}
virtual T1 f1();
virtual T2 f2();
};
template<class T1, class T2>
T1 Base<T1, T2>::f1() {return T1();}
template<class T1, class T2>
T2 Base<T1, T2>::f2() {return T2();}
class Derived : public Base<int, int> {
public:
virtual ~Derived() {}
};
int _tmain(int argc, _TCHAR* argv[])
{
int i;
Derived d;
i = d.f1();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我分解时,我得到了未解析的外部符号:
main.cpp中
#include <windows.h>
#include <tchar.h>
#include "Base.h"
#include …Run Code Online (Sandbox Code Playgroud) 我试图在Windows上使用MinGW编译一个非常简单的程序,但我仍然遇到链接错误.要编译的程序只是C++ hello world.
Z:\dev>type test.cpp
#include <iostream>
int main() {
std::cout << "Hello World!\n";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当然,只需使用MinGW的g ++即可.
Z:\dev>g++ test.cpp -o test.exe
Z:\dev>test.exe
Hello World!
Run Code Online (Sandbox Code Playgroud)
但是,我试图分离编译和链接,但失败了.
Z:\dev>g++ -c test.cpp -o test.o
Z:\dev>ld test.o -o test.exe
test.o:test.cpp:(.text+0xa): undefined reference to `__main'
test.o:test.cpp:(.text+0x19): undefined reference to `std::cout'
test.o:test.cpp:(.text+0x1e): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& s
<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
test.o:test.cpp:(.text+0x37): undefined reference to `std::ios_base::Init::~Init()'
test.o:test.cpp:(.text+0x5a): undefined reference to `std::ios_base::Init::Init()'
test.o:test.cpp:(.text+0x66): undefined reference to `atexit'
Run Code Online (Sandbox Code Playgroud)
很明显,我错过了一些图书馆.所以,我试图链接几个MinGW的库,但仍然没有好处,如-lmsvcrt.我也做了lstdc++,但仍然 …
我正在做一个简单的游戏并遇到了一个问题.我收到此错误:
重复的符号_vertices:/ Users/ - /Library/Developer/Xcode/DerivedData/WorkingTitle_skeleton-gcgtpewqagbzyxbauptoayplozbs/Build/Intermediates/WorkingTitle skeleton.build/Debug-iphonesimulator/WorkingTitle skeleton.build/Objects-normal/i386/ViewController.o/Users/ - /Library/Developer/Xcode/DerivedData/WorkingTitle_skeleton-gcgtpewqagbzyxbauptoayplozbs/Build/Intermediates/WorkingTitle skeleton.build/Debug-iphonesimulator/WorkingTitle skeleton.build/Objects-normal/i386/Block.o duplicate symbol _indices in:/Users/ - /Library/Developer/Xcode/DerivedData/WorkingTitle_skeleton-gcgtpewqagbzyxbauptoayplozbs/Build/Intermediates/WorkingTitle skeleton.build/Debug-iphonesimulator/WorkingTitle skeleton.build/Objects-normal/i386/ViewController.o/ Users/ -/Library/Developer/Xcode/DerivedData/WorkingTitle_skeleton-gcgtpewqagbzyxbauptoayplozbs/Build/Intermediates/WorkingTitle skeleton.build/Debug-iphonesimulator/WorkingTitle skeleton.build/Objects-normal/i386/Block.o ld:2个重复的符号表示 rchitecture i386 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)
我尝试过开始一个新项目并再次尝试,但还没有任何工作.我有一个C++背景,有点刚刚跳进Objective-C,所以可能就是这样.
这是我的代码:
ViewController.m:
#import "ViewController.h"
@interface ViewController () {
Block *testBlock;
}
@property (strong, nonatomic) EAGLContext *context;
- (void)setupGL;
- (void)teardownGL;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
GLKView *view = (GLKView *)self.view;
view.context = self.context;
view.drawableMultisample = GLKViewDrawableMultisample4X;
view.drawableStencilFormat = GLKViewDrawableStencilFormatNone;
view.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;
view.drawableDepthFormat = …Run Code Online (Sandbox Code Playgroud) 我正在跟随Frank D. Luna的"使用DirectX11进行3D游戏编程简介"一书.当我尝试构建我的项目时,我收到了这些错误.
>BoxDemo.obj : error LNK2019: unresolved external symbol _D3DX11CompileFromFileW@44 referenced in function "private: void __thiscall BoxApp::BuildFX(void)" (?BuildFX@BoxApp@@AAEXXZ)
>BoxDemo.obj : error LNK2019: unresolved external symbol _D3DX11CreateEffectFromMemory@20 referenced in function "private: void __thiscall BoxApp::BuildFX(void)" (?BuildFX@BoxApp@@AAEXXZ)
>BoxDemo.obj : error LNK2019: unresolved external symbol _DXTraceW@20 referenced in function "private: void __thiscall BoxApp::BuildFX(void)" (?BuildFX@BoxApp@@AAEXXZ)
>d3dApp.obj : error LNK2001: unresolved external symbol _DXTraceW@20
>d3dUtil.obj : error LNK2001: unresolved external symbol _DXTraceW@20
>TextureMgr.obj : error LNK2001: unresolved external symbol _DXTraceW@20
>d3dApp.obj : error LNK2019: unresolved …Run Code Online (Sandbox Code Playgroud) 当我尝试使用最新的xcode(7.1.1)但得到2个链接器错误时出现此错误: 错误消息图像
对于架构的ARMv7未定义的符号:"_objc_readClassPair",从引用:在libarclite_iphoneos.a(arclite.o)LD __ARCLite__load():符号(多个)未找到架构的ARMv7铛:错误:连接器命令,退出代码1(使用失败 - v看看调用)
不知道如何解决这个问题,任何人都可以帮忙吗?非常感谢.
我遇到一系列神秘的链接器错误.我的常规目标和UITest目标构建并执行正常,但UnitTest目标始终失败并出现以下错误.似乎是CoreData的某种问题,但我无法弄清楚为什么它在测试目标上而不是在主目标中出错.我尝试过:1)清除派生数据.2)重新启动xCode 3)清理安装pod
任何关于在哪里寻找问题的帮助将非常感激.我很难过.谢谢!
Undefined symbols for architecture x86_64:
"direct field offset for playolaIphone.AppDelegate.(managedObjectModel.storage in _D550B33DB84959D9A74FD87E48EB7BC7) : __ObjC.NSManagedObjectModel?", referenced from:
playolaIphone.AppDelegate.managedObjectModel.setter : __ObjC.NSManagedObjectModel in MockAppDelegate.o
playolaIphone.AppDelegate.(managedObjectModel.materializeForSet : __ObjC.NSManagedObjectModel).(closure #1) in MockAppDelegate.o
"direct field offset for playolaIphone.AppDelegate.(managedObjectContext.storage in _D550B33DB84959D9A74FD87E48EB7BC7) : __ObjC.NSManagedObjectContext?", referenced from:
playolaIphone.AppDelegate.managedObjectContext.setter : __ObjC.NSManagedObjectContext in MockAppDelegate.o
playolaIphone.AppDelegate.(managedObjectContext.materializeForSet : __ObjC.NSManagedObjectContext).(closure #1) in MockAppDelegate.o
"direct field offset for playolaIphone.AppDelegate.(persistentStoreCoordinator.storage in _D550B33DB84959D9A74FD87E48EB7BC7) : __ObjC.NSPersistentStoreCoordinator?", referenced from:
playolaIphone.AppDelegate.persistentStoreCoordinator.setter : __ObjC.NSPersistentStoreCoordinator in MockAppDelegate.o
playolaIphone.AppDelegate.(persistentStoreCoordinator.materializeForSet : __ObjC.NSPersistentStoreCoordinator).(closure #1) in MockAppDelegate.o
"direct field offset for playolaIphone.AppDelegate.(applicationDocumentsDirectory.storage in …Run Code Online (Sandbox Code Playgroud)