Find the answer to your Linux question:
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. ...
  1. #1
    Just 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?

  2. #2
    Just Joined!
    Join Date
    Mar 2009
    Location
    Norway
    Posts
    52
    Quote Originally Posted by Mughama View Post
    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?
    normally, you can just type
    Code:
    gcc -o exec_name your_prog.c
    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.

    As to the first error: has the object-files been compiled on a unix-machine?
    Code:
    gcc -c your_prog.c
    If this doesn't help, some more info is needed:
    - 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)

  3. #3
    Just 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.

  4. #4
    Just Joined!
    Join Date
    Mar 2009
    Location
    Norway
    Posts
    52
    Quote Originally Posted by Mughama View Post
    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 .
    Sounds very enterpri$e

    Quote Originally Posted by Mughama View Post
    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
    [/CODE]


    [CODE=Mughama;827095]
    As u querried ,the make file has LDFLAGS
    LDFLAGS=$(CC_LIBDIRS) $(ORA_LIBDIRS) $(ADAPTER_LIBDIRS) $(TUX_LIBDIRS)
    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):
    Code:
    vardump :
          @echo "libdirs: $(CC_LIBDIRS)"
          @echo "ora: $(ORA_LIBDIRS)"
          @echo "adapter: $(ADAPTER_LIBDIRS)"
          @echo "tux: $(TUX_LIBDIRS)"
    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.

  5. #5
    Just 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.

  6. #6
    Just Joined!
    Join Date
    Mar 2009
    Location
    Norway
    Posts
    52
    Quote Originally Posted by chishti View Post
    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.
    dude, he's asking about how to link a set of object-files into an executable - how will that differ between bash and csh?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...