Tag: 编译

我的交叉编译器出了什么问题?

我正在尝试编译一个基本程序,我可以在我的mac上交叉编译。 我正在运行Mac OS X Mavericks。 我的交叉编译器是arm-elf-gcc-4.7.3。 我写了一个简单的测试程序,看起来像: int main() { ; return 0; } 当我运行/opt/local/bin/arm-elf-gcc-4.7.3 -o test test.c时,我收到这些错误。 test.c:4:Unknown pseudo-op: .global test.c:4:Rest of line ignored. 1st junk character valued 109 (m). test.c:5:Unknown pseudo-op: .type test.c:5:Rest of line ignored. 1st junk character valued 109 (m). test.c:7:Junk character 64 (@). test.c:7:Rest of line ignored. 1st junk character […]

我该如何编译这个C代码?

我下载了这个源代码(.zip),并希望在我的Mac(OSX 10.11.2)上使用XCode版本7.2(7C68)进行编译。 我开始编译文件fdist.c gcc -o fdist2 -O fdist.c -lm 但它会返回一系列警告和错误(见下文)。 看看文件,我看到它确实看起来不像我习惯的那种代码。 通常,似乎未指定函数返回的对象类型。 README_fdist2没有多大帮助。 有关如何编译代码的指南,但第一行中有一个拼写错误。 我该如何编译这段代码? 以下是命令gcc -o fdist2 -O fdist.c -lm返回的错误和警告 fdist2.c:42:1: warning: type specifier missing, defaults to ‘int’ [-Wimplicit-int] main() ^ fdist2.c:117:3: warning: implicit declaration of function ‘sim1’ is invalid in C99 [-Wimplicit-function-declaration] sim1(init,initot,rm,mu,freq_arr,val_arr,&noall); ^ fdist2.c:119:4: warning: implicit declaration of function ‘my_thetacal’ is invalid […]

使用OpenSSL编译C程序

我是Openssl的新手。 我在ubuntu 16.04上安装了openssl 1.1.0e和libssl-dev。 我试图在openssl文档https://www.openssl.org/docs/man1.1.0/crypto/EVP_DigestInit.html中运行此页面上的示例。 我用这个命令 gcc example1.c -lssl -lcrypto 编译程序。 但我得到以下错误未定义参考错误 我在论坛上看到了相关问题,但找不到解决方案。 如果有人可以帮助指出解决方案,那将是一个很大的帮助。

Eclipse C编译问题

我已经在eclipse中构建了一个C程序,它在编译时运行良好但是在某些时候我改变了我的代码的一部分,然后控制台保持相同的输出,无论我构建它或运行它多少次或更改代码再一次。所以我删除了希望从new开始的二进制文件但是它一直弹出二进制文件没有找到。我应该怎么做请求帮助。谢谢你。

如何使我的检查发生器输出完全正确,而不是C中的“零”

我的Check生成器程序可以完美地处理您输入的任何输入,使其输出数字。 例如,如果我输入“1234.56”,它将输出“一千二百三十四美元和…… 56美分”。 然而,每当我想输出类似“1000”的东西时,它将输出“一千零美元和…… 0美分”。 显然它不是1000零美元,美分非常好,但我希望摆脱那个“零”,但我需要在那里等片刻,如果你输入“0.01”它会输出“零美元和1分“。 代码如下: #include void printNum(int); void printNum2(int); int main() { int a = 0; int b = 0; int c = 0; int d = 0; int num = 0; int printcents; //To convert the float “cents” to an integer. float inclusive; float cents; printf(“Welcome to the IPC144 Cheque Generator!!\n”); […]

从当前目录以外的目录中包含C代码的正确方法

我有两个目录, sorting和searching (同一目录的孩子),有.c源文件和.h头文件: mbp:c $ ls sorting array_tools.c bubble_sort.c insertion_sort.c main selection_sort.c array_tools.h bubble_sort.h insertion_sort.h main.c selection_sort.h mbp:c $ ls searching array_tools.c array_tools.h binary_search.c binary_search.h linear_search.c linear_search.h main main.c 在searching ,我正在构建一个需要使用insertion_sort函数的可执行文件,在insertion_sort.h声明并在insertion_sort.h定义。 以下编译成功生成可执行文件: mbp:searching $ clang -Wall -pedantic -g -iquote”../sorting” -o main main.c array_tools.c binary_search.c linear_search.c ../sorting/insertion_sort.c 但是,我希望能够通过使用#include包含标头然后为编译器提供搜索路径来包含来自任意目录的函数。 我是否需要预先将.c文件预编译为.o文件? clang的man页列出了以下选项: -I Add the specified directory to […]

C:主要没找到,但它就在那里 编译错误

当我编译下面给出的两个.c文件时,我得到一个非常奇怪的错误。 终端编译代码 gcc -I. -o main.c matrix.c -lblas -lgfortran 错误: /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11 […]

从数据部分执行一段代码

我想获取一段代码,将其复制到全局数组中并从那里执行。 换句话说,我试图将一堆指令从代码部分复制到数据部分,然后设置程序计数器以继续从数据部分执行程序。 这是我的代码: #include #include typedef void(*func)(); static void code_section_func() { printf(“hello”); } #define CODE_SIZE 73 // I verified this size in the disassembly of ‘code_section_func’ static long long data[(CODE_SIZE-1)/sizeof(long long)+1]; // I am using ‘long long’ in order to obtain the maximum alignment int main() { func data_section_func = (func)data; memcpy((void*)data_section_func,(void*)code_section_func,CODE_SIZE); data_section_func(); return 0; […]

是否可以从OCaml调用C函数,而不包含类型?

我正试图在OCaml中编写一个(极其微小,简单 – 我不知道我在做什么,让我们真实!)编译器。 我真的想避免在项目中检查任何 ISO-C代码(尽管很好地了解C;这里的目标是专门学习和使用OCaml。)根据这一点,我需要为编译编写一个“运行时” OCaml中的语言,与主项目分开编译,然后将其与编译器本身的输出相关联。 不幸的是,它看起来像任何外部函数 – 甚至那些不接触任何OCaml数据结构/ OCaml堆的函数 – 都应该使用OCaml的C宏构建: CAMLprim value scheme_entry(value unit) { int i; i = 42; return Val_int(i); } 如果我自己发出assembly说明,这可能不是一个选择。 (至少,直到我学到更多东西!) 是否有任何方法(包括hacky – 这是一个个人学习项目)来调用OCaml中的以下非常简单的函数? _scheme_entry: movl $42 %eax ret 作为参考,我正在通过Ghuloum的IACC: http ://ell.io/tt$ocameel

来自java程序的C程序编译

我正在尝试从Linux平台上的java程序编译ac程序。 我的片段是。 ProcessBuilder processBuilder = new ProcessBuilder(“/usr/bin/gcc”, “-c”,”/hipad/UserProject/example.c”); Process proc = processBuilder.start(); 编译java程序时没有错误,但我无法获得.o文件。 我试图找出解决方案,但没有人工作。 任何建议…..