Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Modify Your makefile

If you use makefiles to build your Microsoft application, you need to change the value for the compiler variable to use the Intel® oneAPI DPC++/C++ Compiler. You may also want to review the options specified by CPPFLAGS. For example, a sample Microsoft makefile:

# name of the program PROGRAM = area.exe # names of source files CPPSOURCES = area_main.cpp area_functions.cpp # names of object files CPPOBJECTS = area_main.obj area_functions.obj # Microsoft(R) compiler options CPPFLAGS = /RTC1 /EHsc # Use Microsoft C++(R) CPP = cl # link objects $(PROGRAM): $(CPPOBJECTS) link.exe /out:$@ $(CPPOBJECTS) # build objects area_main.obj: area_main.cpp area_headers.h area_functions.obj: area_functions.cpp area_headers.h # clean clean: del $(CPPOBJECTS) $(PROGRAM)

Modified makefile for the Intel® oneAPI DPC++/C++ Compiler

Before you can run nmake with the Intel® oneAPI DPC++/C++ Compiler, you need to set the proper environment. In this example, only the name of the compiler changed to use icx:

# name of the program PROGRAM = area.exe # names of source files CPPSOURCES = area_main.cpp area_functions.cpp # names of object files CPPOBJECTS = area_main.obj area_functions.obj # Intel(R) DPC++/C++ Compiler options CPPFLAGS = /RTC1 /EHsc # Use the Intel DPC++/C++ Compiler CPP = icx # link objects $(PROGRAM): $(CPPOBJECTS) link.exe /out:$@ $(CPPOBJECTS) # build objects area_main.obj: area_main.cpp area_headers.h area_functions.obj: area_functions.cpp area_headers.h # clean clean: del $(CPPOBJECTS) $(PROGRAM)

With the modified makefile, the output of nmake is similar to the following:

Microsoft (R) Program Maintenance Utility Version 8.00.50727.42 Copyright (C) Microsoft Corporation. All rights reserved. icx /RTC1 /EHsc /c area_main.cpp area_functions.cpp Intel(R) Compiler for applications running on IA-32 or IA-64 Copyright (C) 1985-2006 Intel Corporation. All rights reserved. area_main.cpp area_functions.cpp link.exe /out:area.exe area_main.obj area_functions.obj Microsoft (R) Incremental Linker Version 8.00.50727.42 Copyright (C) Microsoft Corporation. All rights reserved.

Use IPO in makefiles

By default, IPO generates dummy object files containing interprocedural information used by the compiler. To link or create static libraries with these object files requires specific LLVM-provided tools. To use them in your makefile, replace references to link with lld-link and references to lib with llvm-lib. For example:

# name of the program PROGRAM = area.exe # names of source files CPPSOURCES = area_main.cpp area_functions.cpp # names of object files CPPOBJECTS = area_main.obj area_functions.obj # Intel DPC++/C++ Compiler options CPPFLAGS = /RTC1 /EHsc /Qipo # Use the Intel DPC++/C++ Compiler CPP =icx # link objects $(PROGRAM): $(CPPOBJECTS) lld-link.exe /out:$@ $(CPPOBJECTS) # build objects area_main.obj: area_main.cpp area_headers.h area_functions.obj: area_functions.cpp area_headers.h # clean clean: del $(CPPOBJECTS) $(PROGRAM)