LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to link all and make execute (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-link-all-and-make-execute-4175433018/)

dmv571 10-19-2012 03:56 AM

how to link all and make execute
 
I am having an openssl dh_gen.c file which is having cryptlib.h as shared library. I am having cryptlib.h file also, in that cryptlib.h again its having another two shared libraries e_os.h and ms/uplink.h i am also having e_os.h and uplink.h files also and also having one uplink.c file also. now i want to make dh_gen.c to be execute suggest how to link all and make it execute. plz help me

In brief

Code:

dh_gen.c
#include<openssl.h>
#include "cryplib.h"

Code:

cryptlib.h
#include<openssl.h>
#include "e_os.h"
#include "ms/upload.h"

Code:

upload.h
#include<openssl.h>

one more uplink.c file also there now i want to link all these at last i should run dh_gen.c plz help me

shivaa 10-20-2012 12:48 AM

Do you want to execute all header files i.e. library files within a single c executable file? Does your dh_gen.c file has execute permissions?
An executable can simple run by ./<executable-filename> command from a Unix terminal.
So please specify the error message or problem you're facing while running it.

theNbomr 10-20-2012 01:27 PM

To rephrase your question, you want to build C source files (xxxx.c & yyyy.h) into executable binaries. It is possible that in this case, it is as simple as typing
Code:

make dh_gen
This will compile and link dh_gen.c into the executable binary dh_gen. Assuming that the code is syntactically correct, the make command has enough built-in knowledge of building C source code into runtime binaries, that it will usually succeed. It may be that you need to link the dh_gen.o (created by compiling dh_gen.c) with one or more libraries. If that is the case, you will need to identify what libraries, and then either:
  1. run the linker, ld, independently, giving appropriate linker commands to specify which libraries and where they are stored
  2. add some commandline options to the LDFLAGS macro when invoking make
  3. craft a Makefile with the accordant rules and macros.
If the need for a Makefile or more commandline arguments is necessary, post the complete and exact results from the make command here, and someone will be able to advise you.
One last point of clarification; C header files (blahblah.h) are not libraries. They often accompany libraries (libblablah.so.x.y), so that the code that uses the library knows how to access the content of the library.

--- rod.


All times are GMT -5. The time now is 05:13 AM.