感觉还是要学点c才牛逼

2019-04-06

$gcc -o hello hello.c  //-o选项用来指定输出文件的文件名。

gcc *.c -o hello  //使用通配符编译当前目录下的所有c文件

$ gcc -v -x c -E /dev/null  //查看gcc的默认include目录

使用ldd 查看依赖的动态库so  https://www.cnblogs.com/LiuYanYGZ/p/5545835.html

2019-04-07

Android.mk设置编译的是32还是64.https://ask.csdn.net/questions/232666

生成so包:$ gcc test_a.c test_b.c test_c.c -fPIC -shared -o libtest.so

2019-11-13

可能是Android Studio不够完善,写了一个函数,一直报错闪退,编译器没报错,后来发现,我定义是int test4(),

但是没有返回值,加一个return 0;就好了。这个不应该是编译器提示一下的吗,我确实有几年没写c了。

2020-09-13

ghttp已经安装了:

[root@izwz9eo2whsnfgi4ccyqouz test]# gcc main2.c
/tmp/ccRCX9fU.o: In function `main':
main2.c:(.text+0x20): undefined reference to `ghttp_request_new'
main2.c:(.text+0x35): undefined reference to `ghttp_set_uri'
main2.c:(.text+0x43): undefined reference to `http_hdr_Connection'
main2.c:(.text+0x4b): undefined reference to `ghttp_set_header'
main2.c:(.text+0x57): undefined reference to `ghttp_prepare'
main2.c:(.text+0x63): undefined reference to `ghttp_process'
main2.c:(.text+0x6f): undefined reference to `ghttp_get_body'
main2.c:(.text+0x7f): undefined reference to `ghttp_get_body_len'
main2.c:(.text+0xa3): undefined reference to `ghttp_request_destroy'
collect2: error: ld returned 1 exit status

后来改成:gcc main2.c -lghttp  就好了。

2021-08-07

c本身是跨平台,但需要在不同平台编译(前提是语法没有夹带私货【非跨平台语法和变量】)

2024-01-25

win11环境中,我用按住Shift键,鼠标右击,然后选中 “在终端中打开”,然后运行程序(这个程序有用到动态库)。然后执行没任何反应,也没报错,也没打印错误信息。

最初我以为是系统没有找到我自定义的动态库文件。

后来我在win10上运行,居然成功了。经过对比才知道,win11环境下, 按住Shift,鼠标右击打开的其实是Windows PowerShell。

果断切到cmd下运行。主要是cmd下如果找不到动态库,会有提示。

 你可以针对提示的名字,修改动态库的名字,这样就能方便地找到了。

 Linux上如何把自定义动态库让系统识别:

1、临时方案:把你的自定义库的路径放到系统变量里:  命令行下输入:  export LD_LIBRARY_PATH=/root/test/so:$LD_LIBRARY_PATH

2、放到系统动态库目录里。主要有以下几个目录:

在Linux系统中,库文件通常存放在以下路径中

  1. /lib 目录:这是系统最基本的库文件存放位置,包含了系统最基本的动态链接共享库和静态链接库。
  2. /usr/lib 目录:这是用户级别的库文件存放位置,包含了应用程序和软件包安装的库文件。
  3. /usr/local/lib 目录:这是本地安装的库文件存放位置,可以存放用户自行编译的库文件。

 

posted on 2019-04-06 10:29  angelshelter  阅读(286)  评论(0编辑  收藏  举报

导航