GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 08-Jun-2009, 17:58
ajb181 ajb181 is offline
New Member
 
Join Date: Jun 2009
Posts: 5
ajb181 is on a distinguished road

Trying to build object files. problem with make file


Hi. I have been trying to build the object files for a project but they are not been compiled correctly. I had the project compiling correctly with the standard linux gcc compiler but have changed to ST version of it and now am not getting the correct format of object files.

This compiler has been used to correctly compile our linux kernel so i dont think there is a problem there.

this is an example of the make file

Code:
/////////////// enviroment variable setup /////////////// export PROJECT=release-1.1.0-alpha export TOOLCHAIN=uclibcgnueabi # You shouldn't need to change these variables export ARCH=arm export TARGET=arm-fusion-linux export CROSS_COMPILE=${TARGET}-${TOOLCHAIN}- export PRJROOT=${DEVROOT}${PROJECT} export HOST=i686-cross-linux-gnu export PREFIX=/opt OUTPUT_NAME = ms200 ## C Compiler Configuration ## CC = $(CROSS_COMPILE)gcc CC_SPECIAL_FLAGS = $(CPP_FLAGS) -Wall -c -fPIC -D_REENTRANT -DMODULE CC_DEBUG_FLAGS = # -g -ggdb -O0 -DDEBUG -rdynamic -pg CC_RELEASE_FLAGS = -O2 -DNDEBUG CC_OUTPUT_FLAG = -o ## C++ Compiler Configuration ## CXX = $(CC) -E CXX_SPECIAL_FLAGS = $(CC_SPECIAL_FLAGS) CXX_DEBUG_FLAGS = $(CC_DEBUG_FLAGS) CXX_RELEASE_FLAGS = $(CC_RELEASE_FLAGS) CXX_OUTPUT_FLAG = -o CC_FLAGS = $(CC_SPECIAL_FLAGS) $(CC_DEBUG_FLAGS) $(CC_EXTRA_FLAGS) CXX_FLAGS = $(CXX_SPECIAL_FLAGS) $(CXX_DEBUG_FLAGS) $(CXX_EXTRA_FLAGS) SRCS = \ settings_controller.cpp \ app_controller.cpp \ sim_audio_model.cpp \ sim_tuner_model.cpp \ ms200_resources.cpp \ settings_model.cpp \ SettingsElement.cpp \ sim_app_model.cpp \ except.cpp\ main.cpp \ ms_version.cpp OBJ_DIR = obj-$(OUTPUT_NAME) OBJS = $(addprefix $(OBJ_DIR)/, $(subst .c,.$(OBJ_EXT), \ $(subst .cpp,.$(OBJ_EXT), \ $(subst .S,.$(OBJ_EXT), \ $(notdir $(SRCS)))))) $(OBJ_DIR)/%.$(OBJ_EXT): %.cpp $(VERBOSE_)echo; echo "--- Compiling [$< -> $@]" $(VERBOSE_)[ -d $(dir $@) ] || mkdir -p $(dir $@) $(VERBOSE_)$(CXX) $(CXX_FLAGS) $(CXX_OUTPUT_FLAG) $@ $<

but this is producing an object file that just has the expanded cpp file in it not machine code as i would expect.

Thanks in advance for any help. I'm truly stuck at the moment. Make files make my eyes water!
  #2  
Old 08-Jun-2009, 19:35
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,200
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Trying to build object files. problem with make file


Quote:
Originally Posted by ajb181
Code:
... CXX = $(CC) -E #Huh??? Why -E ???
but this is producing an object file that just has the expanded cpp file in it not machine code as i would expect

The -E flag tells the compiler to stop after the preprocessing stage and not to compile anything.

1. Where did the -E come from?

2. What happens if you leave it off?

3. Since CXX is used to indentify the compiler used for .cpp files. Shouldn't you really have something like
Code:
CXX = $(CROSS_COMPILE)g++

Note that the kernel doesn't probably doesn't have any ,cpp files, so the improperly defined CXX is known as "no harm, no foul" as far as compiling the kernel is concerned.

Regards,

Dave
  #3  
Old 08-Jun-2009, 19:56
ajb181 ajb181 is offline
New Member
 
Join Date: Jun 2009
Posts: 5
ajb181 is on a distinguished road
Smile

Re: Trying to build object files. problem with make file


Dave thanks great explanation.. I had just found the problem myself but was unsure why -E was the issue or what it meant.

Thanks a lot mate. you have truly earned your outstanding member title today.
starting to get my head around makefiles..
  #4  
Old 09-Jun-2009, 05:17
Mexican Bob's Avatar
Mexican Bob Mexican Bob is offline
Member
 
Join Date: Mar 2008
Location: Chicxulub, Yucatán
Posts: 221
Mexican Bob is a jewel in the roughMexican Bob is a jewel in the roughMexican Bob is a jewel in the rough

Re: Trying to build object files. problem with make file


Quote:
Originally Posted by ajb181
Dave thanks great explanation.. I had just found the problem myself but was unsure why -E was the issue or what it meant.

Thanks a lot mate. you have truly earned your outstanding member title today.
starting to get my head around makefiles..

Here's a useful tip:

Execute each of the cross tools in your cross tools directory. In my case, since I'm building for a powerpc 440 target, I have something like:

/opt/powerpc-linux-elf/bin/powerpc-linux-elf-gcc

and

-ar
-as
-ld
-objcopy
-objdump
-strip

...etc.

Usually one sets the CROSS_COMPILE environment variable to be the "prefix" before each of the tool names. So, in my case, it would be:

export CROSS_COMPILE=powerpc-linux-elf-

One would also add to ones path the "bin" directory where the tools are located.

Once you can run the tools from any directory by typing the prefix (until tab autocompletes the line to the last hypen) double tab to get an entire list of the tools available.

Execute each one in turn by invoking the --help as follows:

powerpc-linux-elf-gcc --help > ppc-gcc-help.txt

...and keep going until you've got all of the help from each of the tools in their own files named appropriately so that you can tell which is which. The help contents are typically the most commonly used invocations of the tool and can be invaluable resources.

Print these out or save them in a PDF or some common reference. I like to nail them to my forehead for quick reference, because I usually bring my head with me whilst traveling, but not always.

You will also probably want to take a look at the man pages or info pages for GCC to find out which target switches can be used for your particular ARM variant. Look for mtune=


MxB
 
 

Recent GIDBlogReview: Gel laptop cooling pad by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MAKE file assistance emp C++ Forum 13 28-Feb-2008 12:40
File function jamesbond000 C Programming Language 3 28-Mar-2007 23:32
Please Help Me To Build My Calendar!!! suriacute85 Java Forum 0 05-Oct-2006 20:39
Mozilla Thunderbird dsmith Computer Software Forum - Linux 9 01-Mar-2005 12:56
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 12:28

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:01.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.