Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem linking .so file to code.c

Status
Not open for further replies.

lin1900

Newbie
Newbie level 3
Joined
Nov 10, 2022
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
27
Hi, I am having problem linking .so file to my main1.c
At first, I used the command below to create .so file from multiple c source and header files.
arm-linux-gnueabi-gcc -shared -o ~/Docs/examples/libmylib1.so -fPIC *.c -lpthread -ldl -lm
Then I created main1.c file in the same folder (~/Docs/examples) and used the following command to generate another .so file for main1.c that uses libmylib1.so
arm-linux-gnueabi-gcc -shared -o libmain2.so main1.c -idirafter ~/Docs/examples -lmylib1 -lpthread -ldl -lm
So far, it worked fine.
But, when I copy the libmylib1.so file to another folder and try to use it with another code.c file it doesn't work unless I add {-idirafter ~/Docs/examples} and let it know the original location of libmylib1.so. The new folder contains only libmylib1.so and code.c. Here is the command that I used and it isn't working.
arm-linux-gnueabi-gcc -shared -o libcode1.so code.c -idirafter ~/Docs/newlocation -lmylib1 -lpthread -ldl -lm
Any suggestions on how to fix this?
Thanks.
 

Hi, I am having problem linking .so file to my main1.c
At first, I used the command below to create .so file from multiple c source and header files.
arm-linux-gnueabi-gcc -shared -o ~/Docs/examples/libmylib1.so -fPIC *.c -lpthread -ldl -lm
Then I created main1.c file in the same folder (~/Docs/examples) and used the following command to generate another .so file for main1.c that uses libmylib1.so
arm-linux-gnueabi-gcc -shared -o libmain2.so main1.c -idirafter ~/Docs/examples -lmylib1 -lpthread -ldl -lm
So far, it worked fine.
But, when I copy the libmylib1.so file to another folder and try to use it with another code.c file it doesn't work unless I add {-idirafter ~/Docs/examples} and let it know the original location of libmylib1.so. The new folder contains only libmylib1.so and code.c. Here is the command that I used and it isn't working.
arm-linux-gnueabi-gcc -shared -o libcode1.so code.c -idirafter ~/Docs/newlocation -lmylib1 -lpthread -ldl -lm
Any suggestions on how to fix this?
Thanks.

Here are some of my attempts:
abc@abc-TULPAR-T5-V21-4:~/Docs/newlocation$ ls
code.c libmylib1.so
abc@abc-TULPAR-T5-V21-4:~/Docs/newlocation$ arm-linux-gnueabi-gcc -shared -o libcode1.so code.c -L ~/Docs/newlocation -lmylib1 -lpthread -ldl -lm
code.c:1:10: fatal error: comm_genlib.h: No such file or directory
1 | #include "comm_genlib.h"
| ^~~~~~~~~~~~~~~
compilation terminated.
abc@abc-TULPAR-T5-V21-4:~/Docs/newlocation$ arm-linux-gnueabi-gcc -shared -o libcode1.so code.c -L ~/Docs/newlocation -idirafter ~/Docs/examples -lmylib1 -lpthread -ldl -lm
abc@abc-TULPAR-T5-V21-4:~/Docs/newlocation$ ls
code.c libcode1.so libmylib1.so
I don't know why it works when I added -idirafter ~/Docs/examples
 

Hi, I am having problem linking .so file to my main1.c
At first, I used the command below to create .so file from multiple c source and header files.
arm-linux-gnueabi-gcc -shared -o ~/Docs/examples/libmylib1.so -fPIC *.c -lpthread -ldl -lm
Then I created main1.c file in the same folder (~/Docs/examples) and used the following command to generate another .so file for main1.c that uses libmylib1.so
arm-linux-gnueabi-gcc -shared -o libmain2.so main1.c -idirafter ~/Docs/examples -lmylib1 -lpthread -ldl -lm
So far, it worked fine.
But, when I copy the libmylib1.so file to another folder and try to use it with another code.c file it doesn't work unless I add {-idirafter ~/Docs/examples} and let it know the original location of libmylib1.so. The new folder contains only libmylib1.so and code.c. Here is the command that I used and it isn't working.
arm-linux-gnueabi-gcc -shared -o libcode1.so code.c -idirafter ~/Docs/newlocation -lmylib1 -lpthread -ldl -lm
Any suggestions on how to fix this?
Thanks.
Header files were missing. I included the header files along with .so file. Now the issue is solved.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top