Tag: 编译

如何编译基本的D-Bus / glib示例?

我正在尝试学习如何使用带有C绑定的D-Bus。 我以前从未使用过D-Bus。 我正在学习本教程 ,我认为这是官方教程 (Freedesktop.org)。 我已经读过它,直到这个段落给出了第一个示例程序,但不幸的是我在这个页面上没有看到任何关于如何编译它或包含哪些库的指示。 我错过了什么 ? 我的操作系统是Ubuntu 10.04 32bit。 我安装了libdbus-glib-1-dev软件包。 我尝试在源文件的开头添加#include ,并使用 $ gcc -ldbus-1 -I/usr/include/dbus-1.0/ -I/usr/lib/i386-linux-gnu/dbus-1.0/include -o my_dbus.bin my_dbus.c 但我一直都在失败: my_dbus.c: In function ‘main’: my_dbus.c:7:3: error: unknown type name ‘DBusGConnection’ my_dbus.c:8:3: error: unknown type name ‘GError’ … 我是否错过了教程中的一点? 不,你能帮我编译一下这段代码吗? 提前致谢。

使用gcc编译C时,预处理的.i文件中的数字含义是什么?

我想了解编译过程。 我们可以使用以下命令查看预处理器中间文件: gcc -E hello.c -o hello.i 要么 cpp hello.c > hello.i 我大致知道预处理器的作用,但我很难理解某些行中的数字。 例如: # 1 “/usr/include/stdc-predef.h” 1 3 4 # 1 “” 2 # 1 “hello.c” # 1 “/usr/include/stdio.h” 1 3 4 # 27 “/usr/include/stdio.h” 3 4 # 1 “/usr/include/features.h” 1 3 4 # 374 “/usr/include/features.h” 3 4 这些数字可以帮助调试器显示行号。 所以我对第一列的猜测是第2列文件的行号。 但是以下数字有什么作用?

使用stdprn时的C编译错误

我的操作系统是:Windows 8 IDE:VS 2012 这是我的C程序。 (来自书) /* print_it.c—This program prints a listing with line numbers! */ #include #include void do_heading(char *filename); int line = 0, page = 0; int main( int argv, char *argc[] ) { char buffer[256]; FILE *fp; if( argv 1) fprintf( stdprn, “\f” ); fprintf( stdprn, “Page: %d, %s\n\n”, page, filename ); […]

使用gcc通过javacode编译C源代码

我试图使用exec方法通过java代码编译c文件 String inputFilePath = “\”D:\\Soft\\WebApplication\\build\\web\\code\\Demo.c\””; String[] commands = {“cmd”, “/c”, “gcc”,inputFilePath,”-o”,”Demo”}; Process p=Runtime.getRuntime().exec(commands); DataInputStream din=new DataInputStream(p.getErrorStream()); String s=””,temp; while((temp=din.readLine())!=null) s+=temp; if(s.equals(“”)){ cf.setResult(“No Syntax Error”); } else cf.setResult(s); 但它不会生成demo.exe文件

如何编译这个C程序?

当我输入gcc gprof-helper.c来编译程序时,我得到以下错误: gprof-helper.c: In function `wooinit’: gprof-helper.c:38: error: `RTLD_NEXT’ undeclared (first use in this function) gprof-helper.c:38: error: (Each undeclared identifier is reported only once gprof-helper.c:38: error: for each function it appears in.) 这是程序文件: #define _GNU_SOURCE #include #include #include #include #include static void * wrapper_routine(void *); /* Original pthread function */ static int (*pthread_create_orig)(pthread_t *__restrict, __const […]

在Visual Studio 2010中编译C不创建.EXE文件

我能够在Visual Studio 2008中调试C程序并构建它。 但是,构建过程似乎没有在它构建的文件夹中留下.exe。无论我选择Release还是Debug。 .exe可以发送到其他地方吗? 我该怎么说? 项目主文件夹下Debug文件夹的内容: cl.command.1.tlog CL.read.1.tlog CL.write.1.tlog ConsoleApp.Build.CppClean.log ConsoleApp.exe.embed.manifest ConsoleApp.exe.embed.manifest.res ConsoleApp.exe.intermediate.manifest ConsoleApp.lastbuildstate ConsoleApp.log ConsoleApp.obj ConsoleApp_manifest.rc link-cvtres.read.1.tlog link-cvtres.write.1.tlog link.1504-cvtres.read.1.tlog link.1504-cvtres.write.1.tlog link.1504.read.1.tlog link.1504.write.1.tlog link.command.1.tlog link.read.1.tlog link.write.1.tlog mt.command.1.tlog mt.read.1.tlog mt.write.1.tlog rc.command.1.tlog rc.read.1.tlog rc.write.1.tlog stdafx.obj vc100.idb vc100.pdb

编译和链接C和C ++文件

我想从C文件中调用C ++函数,我已经阅读了有关extern“C”构造和包装器API的内容。 但是,我不确定如何组织各种头文件以及如何链接目标文件。 假设我有一个C文件MyProg.c及其相应的头文件MyProg.h 。 现在,我创建了两个文件Wrapper.cpp和Wrapper.h ,它们声明了我希望从MyProg.c调用的函数。 // Wrapper.h #include “Utility.h” #ifdef __cplusplus extern “C” { #endif void func_to_invoke(); #ifdef __cplusplus } #endif 请注意,Wrapper.h包含一个包含其他实用程序C ++函数的文件。 问题是如何编译和链接文件。 我应该做以下事情: g++ -c Utility.cpp Utility.h g++ -c Wrapper.cpp Wrapper.h Utility.h gcc -c MyProg.c MyProg.h Wrapper.h gcc MyProg.o Wrapper.o 编辑: 我尝试过以下内容,但仍然无法编译。 我有与C ++库相关的页面和错误页面。 我是否还要在__cplusplus宏中声明Utility.h中的所有函数? g++ -c Utility.cpp g++ -c Wrapper.cpp […]

头文件不能工作-undefined引用`method’

头文件似乎无法正常工作。 我是C的新手,并不知道我在做什么 error – findvals.c:(.text+0x561): undefined reference to `approxEqual’ findvals.c #include #include #include #include #include “utils.h” int main(int argc, char **argv) { //printf(“GRR ENTAR SOMETHANG”); //char word[64]; //scanf(“%s”, word); int count = 0; int ret; double x; double y; int i = 0; int c = 0; char *refStr, *tolStr; double refDub; double tolDub; int […]

在f2py中设置fortran编译器

我试图运行f2py 示例来创建编译的扩展模块¶: # import os # os.environ[“CC”] = “gcc” # os.environ[“CXX”] = “g++” # Using post-0.2.2 scipy_distutils to display fortran compilers from scipy_distutils.fcompiler import new_fcompiler compiler = new_fcompiler() # or new_fcompiler(compiler=’intel’) compiler.dump_properties() #Generate add.f wrapper from numpy import f2py with open(“add.f”) as sourcefile: sourcecode = sourcefile.read() print ‘Fortran code’ print sourcecode # f2py.compile(sourcecode, modulename=’add’, extra_args […]

获取已安装程序的编译信息

我需要获取用于构建已安装程序的C编译器的信息。 我猜rt或者lib可以报告,但没有具体的。 并不是程序将安装在/usr/…或类似的地方,因此无法访问构建目录以获取相关信息。