Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C连接错误(带变矩器离合器)_C_Linker Errors_Undefined Symbol_Tcc_Lib - Fatal编程技术网

C连接错误(带变矩器离合器)

C连接错误(带变矩器离合器),c,linker-errors,undefined-symbol,tcc,lib,C,Linker Errors,Undefined Symbol,Tcc,Lib,我试图从(tcc-0.9.26-win64-bin.zip)运行名为libtcc\u test.c的示例 我已将libtcc.h从libtcc复制到include中,并将libtcc.def复制到lib 然后我运行了tcc./examples/libtcc\u test.c,得到了一个链接错误:/ tcc: error: undefined symbol 'tcc_new' tcc: error: undefined symbol 'tcc_set_lib_path' tcc: error: u

我试图从(tcc-0.9.26-win64-bin.zip)运行名为
libtcc\u test.c
的示例

我已将
libtcc.h
libtcc
复制到
include
中,并将
libtcc.def
复制到
lib

然后我运行了
tcc./examples/libtcc\u test.c
,得到了一个链接错误:/

tcc: error: undefined symbol 'tcc_new'
tcc: error: undefined symbol 'tcc_set_lib_path'
tcc: error: undefined symbol 'tcc_set_output_type'
tcc: error: undefined symbol 'tcc_compile_string'
tcc: error: undefined symbol 'tcc_add_symbol'
tcc: error: undefined symbol 'tcc_relocate'
tcc: error: undefined symbol 'tcc_get_symbol'
tcc: error: undefined symbol 'tcc_delete'
我错过了什么


更多信息:

P:\cpp\tcc>tcc ./examples/libtcc_test.c -vv
tcc version 0.9.26 (i386 Win32)
-> ./examples/libtcc_test.c
-> p:/cpp/tcc/include/stdlib.h
->  p:/cpp/tcc/include/_mingw.h
->   p:/cpp/tcc/include/stddef.h
->   p:/cpp/tcc/include/stdarg.h
->  p:/cpp/tcc/include/limits.h
->  p:/cpp/tcc/include/sec_api/stdlib_s.h
->   p:/cpp/tcc/include/stdlib.h
->  p:/cpp/tcc/include/malloc.h
-> p:/cpp/tcc/include/stdio.h
->  p:/cpp/tcc/include/vadefs.h
->  p:/cpp/tcc/include/sec_api/stdio_s.h
->   p:/cpp/tcc/include/stdio.h
-> p:/cpp/tcc/include/string.h
->  p:/cpp/tcc/include/sec_api/string_s.h
->   p:/cpp/tcc/include/string.h
-> p:/cpp/tcc/include/libtcc.h
-> p:/cpp/tcc/lib/libtcc1.a
-> p:/cpp/tcc/lib/msvcrt.def
-> p:/cpp/tcc/lib/kernel32.def
tcc: error: undefined symbol 'tcc_new'
tcc: error: undefined symbol 'tcc_set_lib_path'
tcc: error: undefined symbol 'tcc_set_output_type'
tcc: error: undefined symbol 'tcc_compile_string'
tcc: error: undefined symbol 'tcc_add_symbol'
tcc: error: undefined symbol 'tcc_relocate'
tcc: error: undefined symbol 'tcc_get_symbol'
tcc: error: undefined symbol 'tcc_delete'

要在库中链接,需要在所有
c
文件或
o
文件之后添加
-l${library\u basename}
标志。 如果库名为
libtcc.a
libtcc.so
(在Windows上可能是
tcc.dll
libtcc.dll
),则需要添加
-ltcc

tcc  ./examples/libtcc_test.c  -ltcc
如果要链接的库不是系统的标准库目录,您可能还需要添加
-L
标志以添加搜索路径:

tcc -L . ./examples/libtcc_test.c -ltcc
#also look for libtcc.so or libtcc.a in the current directory (.)
tinycc repo中的
test/libtcc_test.c
中的
libtcc_test.c
也需要
dl
库(用于动态加载的标准库)来构建:

tcc -L .  tests/libtcc_test.c  -ltcc -ldl #worked 

(它抱怨未定义的
dlopen
dlclose
、和
dlsym
,这些都来自
libdl
)。

以下命令在Windows上起作用:

cd your-tcc-directory
tcc -Ilibtcc -L. -ltcc examples/libtcc_test.c
您可能需要添加
-run
以跳过生成exe文件并直接运行源代码

我在Linux上试过,但找不到
libtcc.h
。我想以下方法可以奏效(注意
-ltcc1
而不是
-ltcc
):


您需要链接libs并包含文件,以编译代码。确保你用必要的lib和header链接和包含。我对c非常陌生,但有#include“libtcc.h”和tcc-vv的输出也表明它已添加,但我不知道如何“加载”。deffile@LethalProgrammer:“…需要针对…包含文件进行链接…”包含的(头)文件在链接阶段不使用,但仅在编译期间使用,这是在链接时完成的。
tcc -I/path/to/libtcc.h/location -L/usr/lib/tcc/x86-64 -ltcc1 path/to/libtcc_test.c