Tag: undefined reference

未定义的引用`__ubsan_handle_nonnull_arg’

我一直在研究问题集拼写器的最后几天,到目前为止这就是我所拥有的。 不幸的是,它没有编译,我有点迷失。 如果有人可以帮助我告诉我,我做错了什么,我将非常感激。 // Implements a dictionary’s functionality #include #include #include #include #include #include “dictionary.h” #define HASHTABLE_SIZE 65536 // A struct for a node typedef struct node { // Length is up to 45 + 1 for the Null char word[LENGTH + 1]; // A pointer to the next node struct node *next; } node; […]

什么是未定义的引用/未解析的外部符号错误,如何解决?

什么是未定义的引用/未解析的外部符号错误? 什么是常见原因以及如何修复/预防它们? 随意编辑/添加自己的。

…未定义引用… collect2:ld返回1退出状态

编译时我遇到了一些错误,我无法弄清楚为什么……我的heapsort.h应该有导出类型吗? heapsort.c #include // standard libraries already included in “list.h” #include #include “heap.h” #include “heapsort.h” void heapSort(int* keys, int numKeys){ heapHndl H = NULL; H = buildHeap(numKeys, keys, numKeys); for (int i = 1; i < numKeys; i++){ keys[i] = maxValue(H); deleteMax(H); } freeHeap(&H); } heapsort.h: #ifndef _HEAPSORT_H_INCLUDE_ #define _HEAPSORT_H_INCLUDE_ #include #include void heapSort(int* keys, […]

对我自己的库的未定义引用

我用几个创建了我的lib.a文件 gcc -c file.c -o file.o 然后 ar sr lib/libtest.a file1.o file2.o file3.o 确认 ar -t lib/libtest.a file1.o file2.o file3.o 但是当我尝试编译测试应用程序时 gcc lib/libtest.a test.c -o test 我在函数main得到了未定义的引用:来自file1.o,file2.o,file3.o的函数

链接libavcodec和libavformat:未定义的引用

我正在尝试编译我正在使用ffmpeg库的项目。 该项目用C语言编写。头文件适当地包含在源代码中。 特别是,它似乎使用libavcodec和libavformat ,并且这些库在Makefile中与LDFLAGS正确链接。 以下是使用的标志: -lavcodec -lavformat -lswscale -lavutil 现在,因为Ubuntu附带的打包库太过时了,我下载了ffmpeg的最新源代码,编译并安装它。 我删除了通过包管理器安装的所有打包库。 现在,尽管添加了上面的标志,我得到了很多未定义的引用,我似乎无法解决它。 以下是关于未定义引用的输出: //usr/local/lib/libavcodec.a(cscd.o): In function `decode_frame’: /home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/cscd.c:91: undefined reference to `uncompress’ //usr/local/lib/libavcodec.a(dxa.o): In function `decode_frame’: /home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/dxa.c:250: undefined reference to `uncompress’ //usr/local/lib/libavcodec.a(exr.o): In function `pxr24_uncompress’: /home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/exr.c:784: undefined reference to `uncompress’ //usr/local/lib/libavcodec.a(exr.o): In function `zip_uncompress’: /home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/exr.c:259: undefined reference to `uncompress’ //usr/local/lib/libavcodec.a(flashsv.o): In function `flashsv_decode_block’: /home/abhijitv/Downloads/ffmpeg-2.5/libavcodec/flashsv.c:191: undefined […]

如何从OpenSSL中的perl脚本生成程序集文件

在OpenSSL(版本1.1.0e)的开源代码中,我看到一些函数定义是由文件夹中存在的perl文件生成的。 在加密中每个文件夹中的build.info文件中,他们写了一些行来从相应的.pl生成.s。 例如: 在crypto/aes/build.info生成crypto/aes/build.info : GENERATE[aesp8-ppc.s]=asm/aesp8-ppc.pl $(PERLASM_SCHEME) 在crypto/build.info生成crypto/build.info : GENERATE[ppccpuid.s]=ppccpuid.pl $(PERLASM_SCHEME) 而且在主Makefile(生成的makefile)中,有一些行如下: crypto/aes/aes-x86_64.o: crypto/aes/aes-x86_64.s $(CC) -I. -Icrypto/include -Iinclude $(CFLAGS) $(LIB_CFLAGS) -MMD -MF crypto/aes/aes-x86_64.d.tmp -MT $@ -c -o $@ crypto/aes/aes-x86_64.s @touch crypto/aes/aes-x86_64.d.tmp @if cmp crypto/aes/aes-x86_64.d.tmp crypto/aes/aes-x86_64.d > /dev/null 2> /dev/null; then \ rm -f crypto/aes/aes-x86_64.d.tmp; \ else \ mv crypto/aes/aes-x86_64.d.tmp crypto/aes/aes-x86_64.d; \ fi 其次是: crypto/aes/aes-x86_64.s: crypto/aes/asm/aes-x86_64.pl […]

对memcpy_s的未定义引用

我正在尝试修复对memcpy_s()错误的未定义引用。 我在我的文件中包含了string.h , memcpy()函数运行正常,我也尝试过包含memory.h 。 我在x64 Windows 7上并使用gcc 4.8.1进行编译。 #include #include #include void doMemCopy(char* buf, size_t buf_size, char* in, int chr) { memcpy_s(buf, buf_size, in, chr); } buf内存已在main函数中分配,该函数调用doMemCpy(buf, 64, in, bytes) 。 in是从标准输入读取的字符串 来自cmd终端的确切错误: 未定义引用“memcpy_s”collect2.exe:错误:ld返回1退出状态

Cplex库gcc编译链接错误

gcc -I/opt/cplex-studio-125/cplex/include -lcplex -L/opt/cplex-studio-125/cplex/lib/x86-64_sles10_4.1/static_pic mipex1.c 我正在尝试从cplex编译一个例子。 -I选择没问题。 -L选项似乎已损坏,因为它无法找到函数名称。 错误在哪里? 在特定的链接中有一个libcplex.a 。 /tmp/ccf5sKky.o: In function `main’: mipex1.c:(.text+0x9f): undefined reference to `CPXopenCPLEX’ mipex1.c:(.text+0xee): undefined reference to `CPXgeterrorstring’ mipex1.c:(.text+0x125): undefined reference to `CPXsetintparam’ mipex1.c:(.text+0x222): undefined reference to `CPXcreateprob’ mipex1.c:(.text+0x2e1): undefined reference to `CPXcopylp’ mipex1.c:(.text+0x334): undefined reference to `CPXcopyctype’ mipex1.c:(.text+0x380): undefined reference to `CPXmipopt’ mipex1.c:(.text+0x3cc): undefined reference to `CPXgetstat’ […]

如何在程序中包含数据对象文件(图像等)并访问符号?

我使用objcopy将几个资源文件转换为.obj文件,然后将它们与我的程序源代码链接起来。 我可以使用以下代码很好地访问程序中目标文件内的符号,但只能使用GCC / G ++(Cygwin): extern uint8_t data[] asm(“_binary_Resources_0_png_start”); extern uint8_t size[] asm(“_binary_Resources_0_png_size”); extern uint8_t end[] asm(“_binary_Resources_0_png_end”); 该代码在Visual Studio中不起作用,可能是因为VS拥有自己的__asm命令。 我希望通过链接它们将我的程序资源(图像,着色器等)包含在我的最终可执行文件的.data部分中。 但是如何在VC ++中访问目标文件中定义的符号? 我在没有汇编命令的情况下尝试了extern uint8_t _binary_Resources_0_png_start[]或extern “C” uint8_t _binary_Resources_0_png_start[] ,但是我得到了未解决的符号链接错误。

在c程序中获取错误“对gettid的未定义引用”

这是我的线程子例程……在这里,我创建了4个线程并将结构作为参数传递给线程子例程。 我试图用getid()函数打印线程ID, 我收到错误说“未定义的gettid()参考”。 我添加了必要的头文件…… #include #include #include #define ARRAYSIZE 17 #define NUMTHREADS 4 struct ThreadData { int start, stop; int* array; }; void* squarer(void* td) { struct ThreadData* data=(struct ThreadData*) td; int start=data->start; int stop=data->stop; int* array=data->array; int i; pid_t tid1; tid1 = gettid(); //error at this statement//` printf(“tid : %d\n”,tid1); for (i=start; i<stop; i++) […]