I am trying to compile a project that depends on PCL and OpenCV.
The CMakeLists.txt looks like:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(pcl_visualizer_viewports)
find_package(PCL 1.2 REQUIRED)
find_package(OpenCV REQUIRED)
message("this is my message " ${OpenCV_LIBRARIES} )
message("this is my message " ${OpenCV_INCLUDE_DIRS} )
message("this is my message " ${OpenCV_INSTALL_PATH} )
include_directories(${PCL_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (pcl_visualizer_demo pcl_visualizer_demo.cpp readInputFile.cpp readInputFile.h defines.h helper.cpp helper.h Image_Safety.h Image_Safety.cpp)
target_link_libraries (pcl_visualizer_demo ${PCL_LIBRARIES} ${OpenCV_LIBRARIES})
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
The result is however a segmentation fault and core dumped. I have read through the Cmake tutorial, but I have not found the issue. CMake generates the object files for all:
Scanning dependencies of target pcl_visualizer_demo
[ 20%] Building CXX object CMakeFiles/pcl_visualizer_demo.dir/Image_Safety.cpp.o
[ 40%] Building CXX object CMakeFiles/pcl_visualizer_demo.dir/helper.cpp.o
[ 60%] Building CXX object CMakeFiles/pcl_visualizer_demo.dir/image_converter.cpp.o
[ 80%] Building CXX object CMakeFiles/pcl_visualizer_demo.dir/readInputFile.cpp.o
[100%] Building CXX object CMakeFiles/pcl_visualizer_demo.dir/pcl_visualizer_demo.cpp.o
Linking CXX executable pcl_visualizer_demo
Looking at the linking verbose information, the different object files are mentioned and I interpret this as they are linked.
What am I missing?
update
Weird so the error occurs in some part of the code using basic opencv functions cv::waitKey and cv::imshow, it may seem to be an issue with QT according to this and this.
I had a similar issue. In the end I had to build PCL without QT (I also found several posts which stated interference, but found no solution)
Related
the error broke during the make period
this is the procedure before the error came out
1.download the source code from github of opencv and opencv_contrib 4.3.0
2.creat a dir under opencv source code dir name opencv_contrib
3.enter the build dir and enter the code
cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D CMAKE_BUILD_TYPE=Release -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
some of the files to download while cmake didn't download but I manually download those and all of the fail-to-download files are copied to the required route
then begin to make
make -j7
error break while making
Scanning dependencies of target opencv_test_xfeatures2d
[ 90%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_detectors.cpp.o
[ 90%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_transactions_test.cpp.o
[ 90%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/own/conc_queue_tests.cpp.o
[ 90%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_features2d.cpp.o
[ 90%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_perf_xfeatures2d.dir/perf/perf_surf.ocl.cpp.o
/home/wang/Documents/opencv-4.3.0/opencv_contrib/modules/xfeatures2d/test/test_features2d.cpp: In member function ‘virtual void opencv_test::{anonymous}::Features2d_SIFTHomographyTest_regression_Test::Body()’:
/home/wang/Documents/opencv-4.3.0/opencv_contrib/modules/xfeatures2d/test/test_features2d.cpp:366:88: error: ‘SIFT’ has not been declared
TEST(Features2d_SIFTHomographyTest, regression) { CV_DetectPlanarTest test("SIFT", 80, SIFT::create()); test.safe_run(); }
^~~~
/home/wang/Documents/opencv-4.3.0/opencv_contrib/modules/xfeatures2d/test/test_features2d.cpp: In member function ‘virtual void opencv_test::{anonymous}::Features2d_SIFT_using_mask_regression_Test::Body()’:
/home/wang/Documents/opencv-4.3.0/opencv_contrib/modules/xfeatures2d/test/test_features2d.cpp:435:39: error: ‘SIFT’ has not been declared
FeatureDetectorUsingMaskTest test(SIFT::create());
reference websites
https://www.cnblogs.com/fx-blog/p/8213704.html
https://blog.csdn.net/u011736771/article/details/85960300
I had the same problem with the 4.3.0 release, SIFT was moved out of xfeatures2d but I dont think it was inserted in the main branch for the 4.3.0 release. Just download the master (development) branch and the problem is solved
I am creating an app on the nvidia jetson nano (under ubuntu 18.04 LTS) using Qt-creator. To do so I create my own library (named recolib) which uses opencv (version 3.4.6) and then in my Qt app project I include my library.
The library compiles fine, but when I tried compiling the app it reaches 100% and then I get the following error: undefined reference to `cv::xfeatures2d::SURF::create(double, int, int, bool, bool)'.
Note that the class where this function is called is part of my library "recolib".
I have build opencv with cmake, I have enabled non-free modules and gave the right path to it and opencv built and installed fine.
Moreover, the app works well on mac and on an ubuntu virtual machine.
Here are samples of the Cmakelist.txt of the app:
cmake_minimum_required(VERSION 3.0)
# Add folder where are supportive functions
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11 -pthread -lm")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11 -pthread -lm")
...
find_package(OpenCV REQUIRED)
if(OPENCV_XFEATURES2D_FOUND)
message("xfeatures2d found")
endif()
...
SET(RECOLIB_DIR "${PROJECT_SOURCE_DIR}/libs/recotracking-recolib")
include_directories("${RECOLIB_DIR}/include")
if(WIN32)
link_directories("${RECOLIB_DIR}/build/Debug")
else()
link_directories("${RECOLIB_DIR}/build/")
endif()
SET(RECOLIB_LIBRARY recolib)
include_directories(${OPENCV_INCLUDE_DIRS})
...
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
FILE(GLOB_RECURSE RES_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.qrc")
FILE(GLOB_RECURSE SRC_FILES "${SRC_FOLDER}/*.cpp")
FILE(GLOB_RECURSE UI_FILES "${SRC_FOLDER}/*.ui")
FILE(GLOB_RECURSE HDR_FILES "${HDR_FOLDER}/*.h")
link_directories(${OpenCV_LIBRARY_DIRS})
message("opencv libs: ${OpenCV_LIBRARIES}")
add_executable(${execName} ${OS_BUNDLE}# Expands to WIN32 or MACOS_BUNDLE depending on OS
${RES_FILES} ${SRC_FILES} ${UI_FILES} ${HDR_FILES} ${META_FILES_TO_INCLUDE}
)
...
# Add the Qt5 Widgets for linking
if (APPLE)
target_link_libraries(${execName}
${OpenCV_LIBRARIES}
${AppKit}
${CoreAudio}
${AudioToolbox}
Qt5::Core
Qt5::Gui
Qt5::QuickControls2
Qt5::MultimediaWidgets
Qt5::Multimedia
Qt5::MultimediaPrivate
Qt5::Widgets
Qt5::Sql
${RECOLIB_LIBRARY})
else()
target_link_libraries(${execName}
${OpenCV_LIBRARIES}
Qt5::Core
Qt5::Gui
Qt5::QuickControls2
Qt5::MultimediaWidgets
Qt5::Multimedia
#Qt5::MultimediaPrivate
Qt5::Widgets
Qt5::Sql
${RECOLIB_LIBRARY})
endif()
And the output I get executing it under Qt-creator is the following:
Running "/usr/bin/cmake -E server --pipe=/tmp/cmake-Bg9h0e/socket --experimental" in /home/bookbeo-novatech/build-recotracking-app-Desktop-Release.
Starting to parse CMake project, using: "-DCMAKE_BUILD_TYPE:STRING=Release", "-DCMAKE_CXX_COMPILER:STRING=/usr/bin/g++", "-DCMAKE_C_COMPILER:STRING=/usr/bin/gcc", "-DCMAKE_PREFIX_PATH:STRING=/usr", "-DQT_QMAKE_EXECUTABLE:STRING=/usr/lib/qt5/bin/qmake".
-std=c++11 -pthread -lm
The C compiler identification is GNU 7.4.0
The CXX compiler identification is GNU 7.4.0
Check for working C compiler: /usr/bin/gcc
Check for working C compiler: /usr/bin/gcc -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: /usr/bin/g++
Check for working CXX compiler: /usr/bin/g++ -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Looking for pthread.h
Looking for pthread.h - found
Looking for pthread_create
Looking for pthread_create - not found
Looking for pthread_create in pthreads
Looking for pthread_create in pthreads - not found
Looking for pthread_create in pthread
Looking for pthread_create in pthread - found
Found Threads: TRUE
Found CUDA: /usr/local/cuda (found suitable exact version "10.0")
Found OpenCV: /usr/local (found version "3.4.6")
xfeatures2d found
opencv libs: opencv_calib3d;opencv_core;opencv_cudaarithm;opencv_cudabgsegm;opencv_cudacodec;opencv_cudafeatures2d;opencv_cudafilters;opencv_cudaimgproc;opencv_cudalegacy;opencv_cudaobjdetect;opencv_cudaoptflow;opencv_cudastereo;opencv_cudawarping;opencv_cudev;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_shape;opencv_stitching;opencv_superres;opencv_video;opencv_videoio;opencv_videostab;opencv_aruco;opencv_bgsegm;opencv_bioinspired;opencv_ccalib;opencv_cvv;opencv_datasets;opencv_dnn_objdetect;opencv_dpm;opencv_face;opencv_fuzzy;opencv_hfs;opencv_img_hash;opencv_line_descriptor;opencv_optflow;opencv_phase_unwrapping;opencv_plot;opencv_reg;opencv_rgbd;opencv_saliency;opencv_stereo;opencv_structured_light;opencv_surface_matching;opencv_text;opencv_tracking;opencv_xfeatures2d;opencv_ximgproc;opencv_xobjdetect;opencv_xphoto
Configuring done
Generating done
CMake Warning:
Manually-specified variables were not used by the project:
QT_QMAKE_EXECUTABLE
CMake Project was parsed successfully.
So as you can see, except for some issues with pthread (but it seems unrelated to the main problem), the cmake configuration appears to be good. Opencv is found and xfeatures2d too.
But when I build the app, at the end of the compilation I get:
[ 94%] Building CXX object CMakeFiles/recotracking-app.dir/recotracking-app_autogen/mocs_compilation.cpp.o
[ 97%] Building CXX object CMakeFiles/recotracking-app.dir/recotracking-app_autogen/EWIEGA46WW/qrc_resources.cpp.o
[100%] Linking CXX executable recotracking-app
/home/bookbeo/recotracking-app/libs/recotracking-recolib/build/librecolib.a(PCB.cpp.o): In function `reco::PCB::load(cv::Mat const&, cv::Mat const&, cv::Mat const&, std::vector<reco::RecoPoi, std::allocator<reco::RecoPoi> >)':
CMakeFiles/recotracking-app.dir/build.make:1045: recipe for target 'recotracking-app' failed
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/recotracking-app.dir/all' failed
Makefile:83: recipe for target 'all' failed
/home/bookbeo-novatech/recotracking-app/libs/recotracking-recolib/src/PCB.cpp:47: undefined reference to `cv::xfeatures2d::SURF::create(double, int, int, bool, bool)'
collect2: error: ld returned 1 exit status
make[2]: *** [recotracking-app] Error 1
make[1]: *** [CMakeFiles/recotracking-app.dir/all] Error 2
make: *** [all] Error 2
10:51:49: Le processus "/usr/bin/cmake" s'est terminé avec le code 2.
Erreur lors de la compilation/déploiement du projet recotracking-app (kit : Desktop)
When executing step "CMake Build"
10:51:49: Temps écoulé : 06:59.
I already tried re-building opencv, it didn't change anything, and the module xfeatures2d seems to be found so I don't know where this error is coming from.
If you have any idea, I would really appreciate it.
Thanks in advance.
OpenCV => 3.2
Operating System / Platform => Ubuntu 64 bit
Compiler => make
Detailed description
I am having some trouble installing OpenCV 3.2. I followed the example given on Milq's github: https://github.com/milq/milq/blob/master/scripts/bash/install-opencv.sh; however upon typing the command "make -j4", the process stopped at 23% due to a make error. I then tried this solution: http://www.ozbotz.org/opencv-installation, using the same OpenCV 3.2 zip file from the first solution. However, it stopped again, and I got the following error:
Scanning dependencies of target opencv_cudaarithm
[ 18%] [ 18%] [ 18%] [ 18%] Building CXX object
modules/cudaarithm/CMakeFiles/opencv_cudaarithm.dir/src/core.cpp.o
Building CXX object modules /cudaarithm/CMakeFiles/opencv_cudaarithm.dir/src/element_operations.cpp.o
Building CXX object modules/cudaarithm/CMakeFiles/opencv_cudaarithm.dir/src/reductions.cpp.o
Building CXX object modules/cudaarithm/CMakeFiles/opencv_cudaarithm.dir/src/arithm.cpp.o
Linking CXX shared library ../../lib/libopencv_cudaarithm.so
[ 18%] Built target opencv_cudaarithm
make: *** [all] Error 2
Does anyone have any suggestion or solution to fix this? I have tried recreating it nearly 5 times, and everytime I receive the same error. I believe it has something to do with cudaarithm. I am pretty new to these types of installations, but I trying my best to learn. I have been able to figure out most things myself and by trial and error, but I am at a loss here.
I have a problem I am unable to understand.
I am trying to code a project using openCV 3.1. I want to code inside the QT Creator Environment, because I'm used to that. I do not necessarily need any QT specific features at the moment, I'm working with Ubuntu 14.04.
The problem is, that whenever I try to build inside the QT Creator, it does not build with the following error, but it works if I build from the command line.
10:57:36: Starting: "/usr/bin/cmake" --build . --target all
Linking CXX executable arucoTest
CMakeFiles/arucoTest.dir/PoseEstimator.cpp.o: In function `PoseEstimator::generateMarkers(std::string, int)':
PoseEstimator.cpp:(.text+0x56): undefined reference to `cv::aruco::getPredefinedDictionary(cv::aruco::PREDEFINED_DICTIONARY_NAME)'
PoseEstimator.cpp:(.text+0xb7): undefined reference to `cv::aruco::drawMarker(cv::Ptr<cv::aruco::Dictionary>&, int, int, cv::_OutputArray const&, int)'
PoseEstimator.cpp:(.text+0x1a9): undefined reference to `cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
CMakeFiles/arucoTest.dir/PoseEstimator.cpp.o: In function `cv::String::~String()':
PoseEstimator.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
CMakeFiles/arucoTest.dir/PoseEstimator.cpp.o: In function `cv::String::String(std::string const&)':
PoseEstimator.cpp:(.text._ZN2cv6StringC2ERKSs[_ZN2cv6StringC5ERKSs]+0x69): undefined reference to `cv::String::allocate(unsigned long)'
collect2: error: ld returned 1 exit status
make[2]: *** [arucoTest] Error 1
make[1]: *** [CMakeFiles/arucoTest.dir/all] Error 2
make: *** [all] Error 2
10:57:36: The process "/usr/bin/cmake" exited with code 2.
So it is some kind of linker error. When I inspect my cmake file and output, I see this:
Running "/usr/bin/cmake /XYZ/arucoTest '-GCodeBlocks - Unix Makefiles'" in /XYZ/arucoTest/testbuild.
-- OpenCV library status:
-- version: 2.4.8
-- libraries: opencv_videostab;opencv_video;opencv_ts;opencv_superres;opencv_stitching;opencv_photo;opencv_ocl;opencv_objdetect;opencv_ml;opencv_legacy;opencv_imgproc;opencv_highgui;opencv_gpu;opencv_flann;opencv_features2d;opencv_core;opencv_contrib;opencv_calib3d
-- include path: /usr/include/opencv;/usr/include
-- Configuring done
-- Generating done
-- Build files have been written to: /XYZ/arucoTest/testbuild
As you can see, it only finds openCV 2.4.8, which I still need because of old ROS Indigo projects. However, if I execute the exact same cmake file and build from the commandline, it works perfectly:
username#pc:/XYZ/arucoTest/build$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- OpenCV library status:
-- version: 3.1.0
-- libraries: opencv_xphoto;opencv_xobjdetect;opencv_ximgproc;opencv_xfeatures2d;opencv_tracking;opencv_text;opencv_surface_matching;opencv_structured_light;opencv_stereo;opencv_saliency;opencv_rgbd;opencv_reg;opencv_plot;opencv_optflow;opencv_line_descriptor;opencv_fuzzy;opencv_face;opencv_dpm;opencv_dnn;opencv_datasets;opencv_ccalib;opencv_bioinspired;opencv_bgsegm;opencv_aruco;opencv_viz;opencv_videostab;opencv_videoio;opencv_video;opencv_superres;opencv_stitching;opencv_shape;opencv_photo;opencv_objdetect;opencv_ml;opencv_imgproc;opencv_imgcodecs;opencv_highgui;opencv_flann;opencv_features2d;opencv_core;opencv_calib3d
-- include path: /usr/local/include/opencv;/usr/local/include
-- Configuring done
-- Generating done
-- Build files have been written to: /XYZ/arucoTest/build
veith#roethlinLT:/XYZ/arucoTest/build$ make
Scanning dependencies of target arucoTest
[100%] Building CXX object CMakeFiles/arucoTest.dir/PoseEstimator.cpp.o
Linking CXX executable arucoTest
[100%] Built target arucoTest
As you can see I'm building in 2 different folders, because I found that if I cmake in the same folder, it does not work, even if I remove everything in that folder and cmake again from the command line. Also notice, that it finds 2 different include paths depending on where I start the cmake from.
My makefile looks like this (not very crazy), I'm using this exact same file for both cases.
project(arucoTest)
cmake_minimum_required(VERSION 2.8)
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
set(HEADER_LIST PoseEstimator.h)
set(SRC_LIST PoseEstimator.cpp)
add_executable(${PROJECT_NAME} ${SRC_LIST})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
Using ccmake and the QT build in inspection window, I see that the OpenCV_DIR variable is set to 2 different things: On command line:
OpenCV_DIR /usr/local/share/OpenCV
In QT Creator:
OpenCV_DIR /ust/share/OpenCV
How do I set this to automatically select the right folder inside QT Creator as well? I really have no idea what could cause this!
Thanks!
Cache variable OpenCV_DIR is set by searching with command find_package (in config mode). While search mechanism is fully deterministic (it is described in the doc), it uses some envorinment variables which may differ under your shell and in QT Creator.
Just a guess, QT Creator may set CMAKE_PREFIX_PATH environment variable to contain /usr directory, so it finds an installation under /usr before one under /usr/local.
For choose specific OpenCV installation, just set OpenCV_DIR cache variable accordingly and rerun configuration process.
I have a copy of OpenCV2.4.0 installed in /usr/local/lib
My program compiled properly but when the linker is evoked, it gave errors such as:
/home/zhouw/moos-ivp-zhouw/trunk/src/pATRTest/mst.cpp:661: undefined reference to 'cv::_OutputArray::_OutputArray(cv::Mat const&)'
CMakeFiles/pATR.dir/mst.cpp.o:/home/zhouw/moos-ivp-zhouw/trunk/src/pATRTest/mst.cpp:675: more undefined references to `cv::_OutputArray::_OutputArray(cv::Mat const&)'
collect2: ld returned 1 exit status
make[2]: *** [../bin/pATR] Error 1
make[1]: *** [src/pATRTest/CMakeFiles/pATR.dir/all] Error 2
make: *** [all] Error 2
The strange thing is my program uses opencv intensively, if CMake has trouble finding the libraries, it should have complained a lot more undefined references than jsut a few.
I tried adding
LINK_DIRECTORIES("/usr/local/lib") in my cmake file but it didn't help.
There's another library called POCO is also installed under /usr/local/lib. My program also links to the POCO libraries, but CMake seems having no trouble finding them.
If I manually link with -L/usr/local/lib, it would link properly without error.
The CMakeLists.txt looks like this
PROJECT(pATR)
#what files are needed?
SET(SRCS
spline.hpp
utils.hpp utils.cpp
mst.hpp mst.cpp
cluster.hpp cluster.cpp
target.hpp target.cpp
detector.hpp detector.cpp
classifier.hpp classifier.cpp
atr.hpp atr.cpp
MOOSAtr.h MOOSAtr.cpp
main.cpp
)
ADD_EXECUTABLE(pATR ${SRCS})
# indicate how to link
#LINK_DIRECTORIES("/usr/local/lib")
TARGET_LINK_LIBRARIES(pATR opencv_core opencv_highgui opencv_imgproc MOOS)
INSTALL(TARGETS
pATR
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)
Any idea what's going on? Many thanks!
If you have CMake 2.8, I recommend using find_package(OpenCV) to load the libraries.
There is an example at http://docs.opencv.org/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html
The CMake file:
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
You're after:
find_package(OPENCV COMPONENTS core imgproc highgui REQUIRED)
From the docs:
Packages with components
Some libraries are not monolithic, but come with one or more dependent
libraries or components. A notable example for this is the Qt library,
which ships (among others) with the components QtOpenGL and QtXml. To
use both of these components, use the following the find_package
command:
find_package(Qt COMPONENTS QtOpenGL QtXml REQUIRED)
also, for more info you may check out the following link.
https://gitlab.kitware.com/cmake/community/wikis/doc/tutorials/How-To-Find-Libraries
I am not sure if it makes sense that CMake can't find the linking libraries. CMake finds your dependencies and generates the Makefile, but it doesn't actually compile and link for you.
Your error are not from CMake, right? They are from make.
I always link manually with this
g++ -o myopencvapp `pkg-config --cflags --libs opencv` myopencvapp.cpp`
when invoking g++.