我到达最后一个链接命令(正在链接实际的可执行文件),但我得到一堆未定义的符号(它们在 cpp 中,对我这个简单的 c 程序员来说看起来很可怕)
--它可能很简单,但我无法得到我应该作为链接器放置的内容(它在这里使用 gcc...?合适吗?g++ 告诉我太多输入文件,哈哈)(ld 返回大部分相同的内容)
无论如何,这很荒谬,我完全陷入困境
感谢您的帮助!
make
Making all in docs
Making all in en
make[2]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all-am'.
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0 -arch armv6 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=2.0 -gdwarf-2 -mthumb -miphoneos-version-min=2.0 -I../include -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk -O0 -arch armv6 -pipe -std=c99 -gdwarf-2 -mthumb -I../include -L../libs -L../../libs -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk -L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib -o mutella -L/usr/local/lib uilocalsocket.o gnumarkedfiles.o uitextmode.o sha1.o sha1thread.o gnuwordhash.o gnulogcentre.o asyncdns.o gnuwebcache.o uiterminal.o uiremote.o …Run Code Online (Sandbox Code Playgroud) 我是 cmake 的新手。它工作得很好,但现在我遇到一些链接错误:
undefined reference to `Json::Reader::Reader()'
undefined reference to `Json::Value::Value(Json::ValueType)'
undefined reference to `Json::Reader::parse(std::basic_istream<char, std::char_traits<char> >&, Json::Value&, bool)'
undefined reference to `google::protobuf::MessageLite::ParseFromArray(void const*, int)'
Run Code Online (Sandbox Code Playgroud)
还有更多这样的类型。
我想我必须在某个地方添加 jsoncpp 库。
这里有人知道如何做到这一点吗?
可能的重复:
LNK2038,迭代器不匹配错误,需要忽略
我有一个第三方静态库,它也与 C/C++ 运行时静态链接。我只有这个库的发布版本。
当我尝试将此库链接到我的应用程序的调试版本时,链接器抱怨静态库的迭代器调试级别 (0) 与我的应用程序的级别 (2) 不匹配。
有没有办法强制链接器忽略这个错误?我希望能够在调试模式下使用此库添加的功能,并且无法获得此库的调试版本。
顺便说一句,我无法立即想到这种定义不匹配会引起的任何问题。
我目前正在尝试编译 CppUTest 库并将其与我的项目链接。我使用 CMake 为 CppUTest 库创建了一个 Visual Studio 2013 解决方案并构建了它。
但是,当我将创建的 CppUTest.lib 链接到我的应用程序时,我收到一个链接器错误,告诉我它找不到多个符号,例如
??0Utest@@QAE@XZ)
或者
?RunAllTests@CommandLineTestRunner@@SAHHPAPAD@Z
现在,当我在 lib 和选项 /LINKERMEMBER 上使用 dumpbin.exe 时,我会得到库中包含名称的符号列表
??0Utest@@QEAA@XZ
和
?RunAllTests@CommandLineTestRunner@@SAHHPEAPEAD@Z
所以实际存在的名称与我的项目期望的名称略有不同,我不知道是什么导致了这个问题。是否有任何编译选项会导致这些更改,或者我是否使用不同的编译器,尽管我认为它是相同的?
我在 GNU/Linux Debian 8.5 下编码
我有一个简单的程序。
如果我用gcc prog.c它编译它就可以了!
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
int main(int argc, char const *argv[]) {
float _f = 3.1415f;
floor(_f);
ceil(_f);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我添加pow(),它会说它找不到pow,我需要添加gcc prog.c -lm以使其正确。
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
int main(int argc, char const *argv[]) {
float _f = 3.1415f;
floor(_f);
ceil(_f);
pow(_f, 2);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
如果我是对的,pow(), ceil(),floor()都是来自<math.h>?
那么,为什么不floor() …
我第一次尝试在 ncurses 中进行试验,但是我在编译源代码时遇到了问题。据我所知,ncurses 已安装并位于正确的目录中。
我的 makefile 非常简单:
.cpp :
g++ -Wall -g -o $* $*.cpp -std=c++11 -lncurses
Run Code Online (Sandbox Code Playgroud)
这是我尝试时的输出 locate ncurses.h
$ locate ncurses.h
/usr/include/ncursesw/ncurses.h
Run Code Online (Sandbox Code Playgroud)
当我检查它是否已安装时
$ dpkg -l | grep ncurses
ii libncurses5:amd64 5.9+20140118-1ubuntu1 amd64 shared libraries for terminal handling
ii libncursesw5:amd64 5.9+20140118-1ubuntu1 amd64 shared libraries for terminal handling (wide character support)
ii libncursesw5-dev:amd64 5.9+20140118-1ubuntu1 amd64 developer's libraries for ncursesw
ii mtr-tiny 0.85-2 amd64 Full screen ncurses traceroute tool
ii ncurses-base 5.9+20140118-1ubuntu1 all basic terminal type definitions
ii ncurses-bin 5.9+20140118-1ubuntu1 …Run Code Online (Sandbox Code Playgroud) 我试图让 CImg 与 Visual Sudio 2017 和 jpeg-9b 一起工作,但由于某种原因它没有。
代码:
#define cimg_use_jpeg
#include "../CImg/CImg.h"
using namespace cimg_library;
#pragma comment(lib, "libjpeg.a")
CImg<unsigned char> image("../images/img.jpg"), visu(500, 400, 1, 3, 0);
Run Code Online (Sandbox Code Playgroud)
第一步是库的构建,在这里我按照说明如何使用MinGW编译器。即使构建成功,生成的库
libjpeg.a在 Visual Studio 解决方案中也是不可链接的。错误信息:
状态错误 LNK2019 未解析的外部符号 __imp___iob 在函数 _output_message 中引用
另一个生成的库libjpeg.dll.a在加载.jpg文件时抛出错误 CImg Exception(图片)
经过几次重建后,问题仍然存在。我也尝试使用 VC 编译器,但找不到调用 build 时所需的win32.mak文件comand nmake -f makefile.vc setup-v10。这个文件的非官方下载在我的电脑上不能正常工作。无法在 Visual Studio 中打开生成的解决方案。
是否有一些解决方法 - 如果没有解决方案?
我需要为 cuda 创建一个共享库。库的编译工作正常,但是当我尝试在我的程序中使用它时 nvcc 返回链接器或 ptxas 错误。
我将问题简化为以下代码。该库必须替换不同的 C 函数(此处:memset)。该库由三个 C++ 文件组成:
#ifndef FILEA_H_
#define FILEA_H_
namespace A {
__device__
void* memset(void* _in, int _val, int _size);
};
#endif
Run Code Online (Sandbox Code Playgroud)
#include "FileA.h"
__device__
void* A::memset(void* _in, int _val, int _size) {
char* tmp = (char*)_in;
for(int i = 0; i < _size; i++) tmp[i] = _val;
return _in;
}
Run Code Online (Sandbox Code Playgroud)
#ifndef TEMPCLASS_H_
#define TEMPCLASS_H_
#include "FileA.h"
namespace A {
template <typename T>
class TC {
public:
__device__
TC() { …Run Code Online (Sandbox Code Playgroud) 我正在尝试编译我的项目并获得multiple definition of function error:
CMakeFiles/OasisTest.dir/Tests/Oasis_test.cpp.o: In function `MinHeap::left(int)':
/home/d_/CODING/CLionProjects/DS1-Course_Wet2/Oasis-2/Tests/../DataStructures/MinHeap.h:56: multiple definition of `MinHeap::MinHeap(int)'
CMakeFiles/OasisTest.dir/Oasis.cpp.o:/home/d_/CODING/CLionProjects/DS1-Course_Wet2/Oasis-2/DataStructures/MinHeap.h:56: first defined here
Run Code Online (Sandbox Code Playgroud)
我的头文件中似乎有变量定义,应该删除或 makeextern或 made inline,但我不知道要更改什么。
注意:我没有成功编译MinHeap.h
我在CMakeLists.txt 中尝试编译的内容:
add_executable(OasisTest
Oasis.cpp
Tests/Oasis_test.cpp
)
Run Code Online (Sandbox Code Playgroud)
最小堆文件
#ifndef OASIS_MINHEAP_H
#define OASIS_MINHEAP_H
#include <iostream>
#include <climits>
using namespace std;
// Prototype of a utility function to swap two integers
void swap(int* x, int* y);
// A class for Min Heap
class MinHeap {
int* harr; // pointer …Run Code Online (Sandbox Code Playgroud) 我正在使用 Z3 源目录中的以下(标准)命令从源代码中使用 OCaml 编译 Z3:
> python scripts/mk_make.py --prefix=$OPAM_SWITCH_PREFIX --ml
然后从build/目录中构建和安装。
然后运行
> utop
和
> #require "z3";;
给了我以下错误:
Cannot load required shared library dllz3ml.
Reason: /home/foobar/.opam/my_opam/lib/stublibs/dllz3ml.so: undefined symbol: Z3_rcf_del.
我对如何调试这些类型的错误感到困惑。是否有任何建议可以确定问题以及如何解决?