Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*

Makefile question

liu_wei67
Beginner
516 Views

hi:

In my project, I intend to provide users with a generic Makefile to compile files for them.

Therefore, I refer to some examples of makefiles provided by Intel official website and makefiles generated in eclipse after integrating dpc++ compiler in eclipse. I find that the same example program compiles slightly different commands. I would like to ask the difference between them and which one is more generic?

 

eclipse vector-add Makefile:

all: main.o

dpcpp -L${DPCPP_CMPLR_ROOT}/lib -o main main.o -lsycl -lOpenCL

 

main.o: main.cpp

DPCPP -c -i ${DPCPP_CMPLR_ROOT}/include -i ${DPCPP_CMPLR_ROOT}/lib/clang/9.0.0/include -o main.o main.cpp

 

Intel's official website vector-add Makefile:

CXX = dpcpp
CXXFLAGS = -O2 -g -std=c++17

BUFFER_EXE_NAME = vector-add-buffers
BUFFER_SOURCES = src/vector-add-buffers.cpp

USM_EXE_NAME = vector-add-usm
USM_SOURCES = src/vector-add-usm.cpp

all: build_buffers

build_buffers:
$(CXX) $(CXXFLAGS) -o $(BUFFER_EXE_NAME) $(BUFFER_SOURCES)

build_usm:
$(CXX) $(CXXFLAGS) -o $(USM_EXE_NAME) $(USM_SOURCES)

run:
./$(BUFFER_EXE_NAME)

run_usm:
./$(USM_EXE_NAME)

clean:
rm -f $(BUFFER_EXE_NAME) $(USM_EXE_NAME)

 

thanks

0 Kudos
3 Replies
VarshaS_Intel
Moderator
492 Views

Hi,


Thanks for reaching out to us.


Both the eclipse-provided makefile as well as the Intel makefile are supported and you can use any of them to generate the output.


>>I find that the same example program compiles slightly different commands.

Yes, even the output for both the makefiles you are specifying is the same but there is a difference in writing the makefile.


>>I would like to ask the difference between them and which one is more generic?

In this Intel's vector-add makefile there is -O2 flag which optimizes the code.

It is a readable and standard form of writing the Makefile. Here, you can specify the compiler, compilation flags and we can also modify the compiler as well as the compilation options at the run time.


In this makefile, we will specify the path of the source file, executable and later we can use it for other codes by just changing the filename. And also, the steps to make the makefile are very easy. So, this is a more generic way to use the makefile.


Thanks & Regards,

Varsha


0 Kudos
liu_wei67
Beginner
481 Views

Hi:

Thanks for your answer, I understand.

Thanks

0 Kudos
VarshaS_Intel
Moderator
459 Views

Hi,


Glad to know that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Thanks & Regards,

Varsha


0 Kudos
Reply