I have a project named ROOTTest and the project has a cpp file named main.cpp.
here are some environment variables:
ROOT_SYS: /opt/root
ROOT_INCLUDE_DIRS: /opt/root/include
ROOT_LIBRARIES: /opt/root/lib
i edit CMakeLists in CLion like this:
cmake_minimum_required(VERSION 3.6)#原始
project(ROOTTest)#原始
set(CMAKE_CXX_STANDARD 11)#原始
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} $ENV{ROOT_SYS}/etc/cmake)
find_package(ROOT REQUIRED COMPONENTS RIO Net)
include_directories($ENV{ROOT_INCLUDE_DIRS})
link_directories(/opt/builddir/lib)
set(SOURCE_FILES main.cpp)#原始
add_executable(ROOTTest ${SOURCE_FILES})#原始
target_link_libraries(ROOTTest -lCore -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic
)
main.cpp is like this:
#include <iostream>
#include <stdlib.h>
#include "TTree.h"
#include "TROOT.h"
#include "TRandom.h"
#include "TFile.h"
#include "TLeaf.h"
#include "TMessage.h"
#include "TBrowser.h"
#include "TTreeReader.h"
#include "TTreeReaderValue.h"
#include "TBuffer.h"
using namespace std;
int main(){
new TBrowser();
return 0;
}
but the result is like this:
/home/mrw/Files/各种学习/各种毕业设计/各种测试/ROOTTest/cmake-build-debug/ROOTTest
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00007f9a6e5a44ca in __GI___waitpid (pid=18271, stat_loc=stat_loc
entry=0x7ffd38cda180, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
#1 0x00007f9a6e51dfbb in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:148
#2 0x00007f9a6f5ac274 in TUnixSystem::Exec (shellcmd=<optimized out>, this=0x223a4f0) at /opt/root/core/unix/src/TUnixSystem.cxx:2073
#3 TUnixSystem::StackTrace (this=0x223a4f0) at /opt/root/core/unix/src/TUnixSystem.cxx:2301
#4 0x00007f9a6f5ae35c in TUnixSystem::DispatchSignals (this=0x223a4f0, sig=kSigSegmentationViolation) at /opt/root/core/unix/src/TUnixSystem.cxx:3539
#5 <signal handler called>
#6 0x0000000000400c34 in hello () at /home/mrw/Files/各种学习/各种毕业设计/各种测试/ROOTTest/main.cpp:39
#7 0x0000000000400d24 in main () at /home/mrw/Files/各种学习/各种毕业设计/各种测试/ROOTTest/main.cpp:53
===========================================================
The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#6 0x0000000000400c34 in hello () at /home/mrw/Files/各种学习/各种毕业设计/各种测试/ROOTTest/main.cpp:39
#7 0x0000000000400d24 in main () at /home/mrw/Files/各种学习/各种毕业设计/各种测试/ROOTTest/main.cpp:53
===========================================================
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
why the program can’t run?