标签: linker-errors

链接器错误:"链接器输入文件未使用,因为链接未完成",未定义引用该文件中的函数

我在链接文件时遇到问题.

基本上,我的计划包括:

  • 主程序,gen1.
  • gen1- 接收输入发送到str2value处理,输出结果str2value,使用"tokenizer"将输入分解为令牌,确定对每个令牌执行何种处理,并将它们传递给str2num,或str2cmd.然后它返回一个结果数组.
  • str2num - 做一些处理
  • str2cmd - 同上
  • author.py-产生一个Python脚本str2cmd.cstr2cmd.h从首标cmdTable.h.

我很确定我的包含正确,我已经检查了几次.我还检查#ifndef了标题中没有条件错误.

这是我的Makefile:

#CPP = g++ -lserial
CPP = g++ -DTESTMODE
C= gcc
DEFINES = LURC
CFLAGS = -Wall -fshort-enums -D$(DEFINES)
PROJECTFILES = gen1.cpp str2value.o

STR2VALUEFILES = str2value.cpp str2cmd.o str2num.o tokenizer.o str2value.h

gen1 : $(PROJECTFILES)
        $(CPP) $(CFLAGS) -o gen1 $(PROJECTFILES)



str2value.o : $(STR2VALUEFILES)
#       echo "str2value"
        $(CPP) $(CFLAGS) -c …
Run Code Online (Sandbox Code Playgroud)

c c++ gcc makefile linker-errors

38
推荐指数
1
解决办法
12万
查看次数

为什么这个"未定义的外部变量"不会导致C++ 17中的链接器错误?

我已经在C++ 17编译器(Coliru)中编译并运行了以下程序.在程序中,我声明了一个extern变量,但没有定义它.但是,编译器不会给出链接器错误.

#include <iostream>

extern int i; // Only declaration

int func() 
{
    if constexpr (true)
        return 0;
    else if (i)
        return i;
    else
        return -1;
}

int main() 
{
    int ret = func();
    std::cout<<"Ret : "<<ret<<std::endl;
}
Run Code Online (Sandbox Code Playgroud)

为什么编译器没有给出链接器错误?

c++ linker-errors extern c++17 if-constexpr

38
推荐指数
3
解决办法
3695
查看次数

未明确引用'vtable for xxx'

takeaway.o: In function `takeaway':
project:145: undefined reference to `vtable for takeaway'
project:145: undefined reference to `vtable for takeaway'
takeaway.o: In function `~takeaway':
project:151: undefined reference to `vtable for takeaway'
project:151: undefined reference to `vtable for takeaway'
takeaway.o: In function `gameCore':
project.h:109: undefined reference to `gameCore<int>::initialData(int)'
collect2: ld returned 1 exit status
make: *** [takeaway] Error 1
Run Code Online (Sandbox Code Playgroud)

我一直从链接器中获取此错误,我知道它与内联函数有关,可以暂时存储vtable.但是这需要我不太确定.我认为这与我如何在takeaway.cpp的启动列表中调用gameCore的构造函数有关

我有一个模板化的类(gameCore.h)和一个继承自gameCore的类(takeaway.cpp)vtable错误被称为3次1)在takeaways构造函数中2)takeaways析构函数3)在gameCores构造函数中

我正在使用G ++这里是代码:(我知道它可能看起来很难读,但我已经标记了错误发生的地方)takeaway.h

#ifndef _TAKEAWAY_H_
#define _TAKEAWAY_H_
#include<map>
#include<cctype>
#include<stack>
#include<map>
#include<iostream>
#include<string>
#include<cstdlib>
#include"gameCore.h"
#include<vector>
using namespace std;
class takeaway : public …
Run Code Online (Sandbox Code Playgroud)

c++ linker linker-errors vtable

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

从Android Studio中的Gitlab克隆存储库时出现"Repositroy test failed"错误?

我想从Android Studio 0.8.1中的gitlab存储库克隆我的android代码.我检查了VCS >>从Version Control中检出>> Git >>在这里添加了HTTP url.它提示我"Repositroy test failed".请帮我解决问题.我也检查了插件.谢谢了很多.

android linker-errors gitlab android-studio

37
推荐指数
1
解决办法
5万
查看次数

制作GTest时出错

我试图在我的Ubuntu机器上设置GTest环境.但在使GTest获取库时,我收到以下错误...

som@som-VPCEH25EN:~/Workspace/CPP/gtest-1.6.0/make$ make
g++ -I../include -g -Wall -Wextra -lpthread sample1.o sample1_unittest.o gtest_main.a -o sample1_unittest
gtest_main.a(gtest-all.o): In function `~ThreadLocal':
/home/som/Workspace/CPP/gtest-1.6.0/make/../include/gtest/internal/gtest-port.h:1336: undefined reference to `pthread_getspecific'
/home/som/Workspace/CPP/gtest-1.6.0/make/../include/gtest/internal/gtest-port.h:1340: undefined reference to `pthread_key_delete'
/home/som/Workspace/CPP/gtest-1.6.0/make/../include/gtest/internal/gtest-port.h:1336: undefined reference to `pthread_getspecific'
/home/som/Workspace/CPP/gtest-1.6.0/make/../include/gtest/internal/gtest-port.h:1340: undefined reference to `pthread_key_delete'
gtest_main.a(gtest-all.o): In function `testing::internal::ThreadLocal<std::vector<testing::internal::TraceInfo, std::allocator<testing::internal::TraceInfo> > >::GetOrCreateValue() const':
/home/som/Workspace/CPP/gtest-1.6.0/make/../include/gtest/internal/gtest-port.h:1372: undefined reference to `pthread_getspecific'
/home/som/Workspace/CPP/gtest-1.6.0/make/../include/gtest/internal/gtest-port.h:1379: undefined reference to `pthread_setspecific'
gtest_main.a(gtest-all.o): In function `testing::internal::ThreadLocal<testing::TestPartResultReporterInterface*>::CreateKey()':
/home/som/Workspace/CPP/gtest-1.6.0/make/../include/gtest/internal/gtest-port.h:1365: undefined reference to `pthread_key_create'
gtest_main.a(gtest-all.o): In function `testing::internal::ThreadLocal<std::vector<testing::internal::TraceInfo, std::allocator<testing::internal::TraceInfo> > >::CreateKey()':
/home/som/Workspace/CPP/gtest-1.6.0/make/../include/gtest/internal/gtest-port.h:1365: undefined reference to `pthread_key_create'
gtest_main.a(gtest-all.o): In function …
Run Code Online (Sandbox Code Playgroud)

linker-errors googletest

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

应用太大了?无法执行dex:无法将新索引合并到非jumbo指令中

编译我的应用程序时出现以下错误:

[2014-05-07 21:48:42 - Dex Loader] Unable to execute dex: Cannot merge new index 65536 into a non-jumbo instruction!
Run Code Online (Sandbox Code Playgroud)

我的观点是,如果我在我的包中的任何地方声明一个新方法,我会收到此错误.如果我没有,该应用程序编译.

我想知道这个错误的确切含义(并准确无误).我的应用程序很大,但我不认为它那么大!所以:

  • 错误是否意味着我有太多方法?上市?静态的?包?成员?
  • 它与我的root包的方法/成员有关,还是与包含的JAR库有关?
  • 有没有办法获得更多关于此的调试信息?

我已经知道在SO中的类似问题中解决了"jumbo"启用标志,但是,我认为jumbo模式在我目标的API级别(ICS)上不可用.

android linker-errors dex

36
推荐指数
4
解决办法
2万
查看次数

如何将C++目标文件与ld链接

我正在尝试使用ld而不是g ++链接C++的输出.我只是这样做是为了学习如何做,而不是为了实际目的,所以请不要建议只用g ++来做.

看看这个问题,这个人在运行ld命令时会得到同样的错误:

$ ld test.o -o test.out
ld: warning: cannot find entry symbol _start; defaulting to 00000000004000e8
test.o: In function `main':
test.cpp:(.text+0x1c): undefined reference to `strcasecmp'
test.cpp:(.text+0x23): undefined reference to `std::cout'
test.cpp:(.text+0x28): undefined reference to `std::ostream::operator<<(int)'
test.cpp:(.text+0x2d): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
test.cpp:(.text+0x35): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
test.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x75): undefined reference to `std::ios_base::Init::Init()'
test.cpp:(.text+0x7a): undefined reference to `__dso_handle'
test.cpp:(.text+0x84): undefined reference to `std::ios_base::Init::~Init()'
test.cpp:(.text+0x89): undefined …
Run Code Online (Sandbox Code Playgroud)

c++ linker linker-errors ld libstdc++

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

Xcode 4.5.1中的"找不到文件","链接器命令失败,退出代码为1"

我正在开发一个现有的iOS应用程序,我必须为这个项目编写单元测试用例.它正在Simulator 6.0中构建和运行.每当我尝试测试项目时,它都会显示以下错误消息.我无法确定准确的错误.

id: file not found: /Users/Yuva/Library/Developer/Xcode/DerivedData/FlyApp-aexukpgtbathuadgxlnm/Build/Products/Debug-iphonesimulator/FlyApp.app/FlyApp
clag: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

你能帮我解决这个链接器错误并测试应用程序吗?

unit-testing linker-errors file-not-found ios

32
推荐指数
6
解决办法
2万
查看次数

导出DLL中的静态数据

我有一个DLL,其中包含一个静态成员的类.我用__declspec(dllexport)它来使用这个类的方法.但是当我将它链接到另一个项目并尝试编译它时,我得到静态数据的"未解析的外部符号"错误.

例如,在DLL中,Test.h

class __declspec(dllexport) Test{
protected:
    static int d;
public:
    static void m(){int x = a;}
}
Run Code Online (Sandbox Code Playgroud)

在DLL中,Test.cpp

#include "Test.h"

int Test::d;
Run Code Online (Sandbox Code Playgroud)

在使用Test的应用程序中,我调用m().

我也尝试分别为每个方法使用__declspec(dllexport),但我仍然得到静态成员的相同链接错误.

如果我使用dumpbin检查DLL(.lib),我可以看到符号已导出.

例如,应用程序在链接时给出以下错误:

1>Main.obj : error LNK2001: unresolved external symbol "protected: static int CalcEngine::i_MatrixRow" (?i_MatrixRow@CalcEngine@@1HA)
Run Code Online (Sandbox Code Playgroud)

但是.lib的dumpbin包含:

Version      : 0
  Machine      : 14C (x86)
  TimeDateStamp: 4BA3611A Fri Mar 19 17:03:46 2010
  SizeOfData   : 0000002C
  DLL name     : CalcEngine.dll
  Symbol name  : ?i_MatrixRow@CalcEngine@@1HA (protected: static int CalcEngine::i_MatrixRow)
  Type         : data
  Name type    : …
Run Code Online (Sandbox Code Playgroud)

c++ windows linker-errors dllexport

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

C++ Builder XE7 LME288错误

突然,突然之间,我得到了LME288链接器错误.

[ilink32 Warning] Warning: D:/Projects/TrainFever Game Manager/TFGM/Win32/Debug/TFGameManager.ilc: 0x00010000 / 0x08000000
[ilink32 Warning] Warning: D:/Projects/TrainFever Game Manager/TFGM/Win32/Debug/TFGameManager.ild: 0x00010000 / 0x08000000
[ilink32 Warning] Warning: D:/Projects/TrainFever Game Manager/TFGM/Win32/Debug/TFGameManager.ilf: 0x00010000 / 0x0a000000
[ilink32 Warning] Warning: D:/Projects/TrainFever Game Manager/TFGM/Win32/Debug/TFGameManager.ils: 0x0003b000 / 0x08000000
[ilink32 Warning] Warning: unknown heap name   : 0x08000000 / 0x08000000
[ilink32 Warning] Warning: Error detected (LME288)
[ilink32 Error] Error: Unable to perform link
Run Code Online (Sandbox Code Playgroud)

我没有安装AV,该项目已经运行了一年多.我试过了:

  • 增量链接器禁用/启用,没有区别......
  • 手动删除/ debug中的所有文件,仍然没有变化......
  • 完全构建,没有区别......
  • 重启电脑,没有变化......

这已经在之前提出过,但没有提出真正的解释或解决方案.

我还能做些什么来解决这个问题?

编辑
我试图重建其他几个运行良好多年的项目,现在我的所有项目都出现了LME288错误.

c++builder linker-errors windows-7-x64 c++builder-xe7

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