LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   makefile (https://www.linuxquestions.org/questions/linux-newbie-8/makefile-891503/)

aydi 07-13-2011 10:28 AM

makefile
 
hello,

i have this make file that i want to use to test hello world:
Code:

CC=        $(shell which ppc_4xx-g++)
CXXFLAGS=-cpp -Wall       
LDFLAGS=       
SOURCES=main.cpp hello.h       
OBJECTS=$(SOURCES:.cpp=.o)       
EXECUTABLE=hello       

all: $(SOURCES) $(EXECUTABLE)       
       
$(EXECUTABLE): $(OBJECTS)       
        $(CC) $(LDFLAGS) $(OBJECTS) -o $@       

.cpp.o:
        $(CC) $(CXXFLAGS) $< -o $@

and hello.h:

Code:

#include <iostream.h>
using namespace std;
void hello(){
  cout << "Hello World!";
}

and main.cpp:

Code:

#include <iostream.h>
#include "hello.h"
using namespace std;
int main(){
    hello();
    cout << endl;
    //cout << "The factorial of 5 is " << factorial(5) << endl;
    return 0;
}

i get a lot of message like that:

main.o:/opt/eldk/build/ppc-2008-04-01/work/usr/src/denx/BUILD/crosstool-0.43/build/gcc-4.2.2-glibc-20070515T2025-eldk/powerpc-linux/build-gcc/gcc/crtsavres.S:283: first defined here
collect2: ld returned 1 exit status
make: *** [hello] Erreur 1

i don't understand what's the problem

can any one help me to solve this problem.

thanks an advance

Noway2 07-13-2011 11:37 AM

Quote:

CC= $(shell which ppc_4xx-g++)
Are you building this for a machine that is based upon Power PC (processor)? Based upon the error message, it looks like you are invoking a cross compiler (crosstool-0.43).
The error message appears to be a linker message, possibly about duplicate defined symbols. Are you able to compile and link without a makefile?

aydi 07-13-2011 11:52 AM

thank you
i solve the pb

grail 07-13-2011 12:41 PM

Quote:

i solve the pb
So please share so others may learn?

You also need to mark your thread as SOLVED.

aydi 07-13-2011 03:33 PM

Code:

CC= $(shell which ppc_4xx-g++)
CXXFLAGS=-c++ -Wall
LDFLAGS=
SOURCES=main.cpp hello.h
OBJECTS=$(SOURCES:.c++=.o)
EXECUTABLE=hello

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@

.cpp.o:
$(CC) $(CXXFLAGS) $< -o $@

this the mexfile for ppc.

for the standard library just keep: #include <iostream> without "h"

it works

good luck

grail 07-13-2011 06:48 PM

Thanks for the update, but you still need to mark as SOLVED.

aydi 07-15-2011 02:35 AM

thanks'.

it's solved.

thanks

grail 07-15-2011 02:49 AM

Yes and if you go to Thread Tools at the top of the page and mark it as such it will advise everyone that it is SOLVED.


All times are GMT -5. The time now is 06:35 AM.