Results 1 to 6 of 6
I have a source file(.C) and its executables.This code was compiled in unix enviroinment.
Now for the same source file(.C) i need to compile and create executable in Linux enviroinment.
...
- 01-31-2011 #1Just Joined!
- Join Date
- Jan 2011
- Posts
- 2
Compile c program in linux
I have a source file(.C) and its executables.This code was compiled in unix enviroinment.
Now for the same source file(.C) i need to compile and create executable in Linux enviroinment.
Could someone help me with the steps to run the ssource code in cross platfrom(here in Linux) ?
I receive the below error
xxxxx.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make: *** [xxxxxxxx] Error 1
Coudl you also post me the steps to compile and create an executable form the source code?
- 01-31-2011 #2Just Joined!
- Join Date
- Mar 2009
- Location
- Norway
- Posts
- 52
normally, you can just type
However, if you have to link in special libraries, or several files (.c and .h) you may be better off to write a short makefile.Code:gcc -o exec_name your_prog.c
As to the first error: has the object-files been compiled on a unix-machine?
If this doesn't help, some more info is needed:Code:gcc -c your_prog.c
- which program are you trying to compile (why have you edited that out?)
- does it link to any special libraries (look for LDFLAGS in the makefile)
- 02-01-2011 #3Just Joined!
- Join Date
- Jan 2011
- Posts
- 2
We use Tuxedo and Elink adapters which retrieve values from the oracle database and these FML type value are converted into XML’s and posted on the MQ.
Each application will have customized Elink adapters apart from the standard built-in ELink adapters. These customized ELink adapters are specific to the application .
Now i need to build these adapters in a linux enviroinment.There are many c files and header files linked.I have a make file to call of them which was developed on an unix enviroinment.Now this has to to be reused on a linux enviroinment.
Am new to C programming.So need to know if we can use the same make file to build the executables in linux? else how to do it
As u querried ,the make file has LDFLAGS
LDFLAGS=$(CC_LIBDIRS) $(ORA_LIBDIRS) $(ADAPTER_LIBDIRS) $(TUX_LIBDIRS)
Thanks in Advance.
- 02-01-2011 #4Just Joined!
- Join Date
- Mar 2009
- Location
- Norway
- Posts
- 52
Sounds very enterpri$e

Ok, doesn't tell me much :s - what I need is the content of the variables listed in LDFLAGS
Anyway, as a start, echo those out in one of the rules and compare that to the content in the unix-env where links successfully
Add something like this in the makefile (note that the indentation *must* be a tab, not spaces as used here):
If the output differs between Linux and Unix, that's probably. You should also verify that all the libraries required are present in your linux-environment.Code:vardump : @echo "libdirs: $(CC_LIBDIRS)" @echo "ora: $(ORA_LIBDIRS)" @echo "adapter: $(ADAPTER_LIBDIRS)" @echo "tux: $(TUX_LIBDIRS)"
- 02-02-2011 #5Just Joined!
- Join Date
- Dec 2010
- Posts
- 2
welcome dear!
in most linux environments default shell for scripting is "bash"! that is not for the c scripts to execute!
first you will have select the "csh" shell for c scripts and then you can execute your scripts having no problem at all.
- 02-02-2011 #6Just Joined!
- Join Date
- Mar 2009
- Location
- Norway
- Posts
- 52


Reply With Quote
