cmake - Bad Reloc Address using MinGW -


i use mingw on windows 7 64bit.

i used google test netbeans (followed bo qian instruction: http://www.youtube.com/watch?v=ts2ctf11k1u&feature=c4-overview-vl&list=pl5jc9xfgsl8gyes7nh-1yqljjdtvifssh&hd=1) , worked correctly. tried link google mock (with google test inside) project. used cmake , cmakelists.txt file:

cmake_minimum_required(version 2.8) project(fs_report)  include_directories(${project_source_dir})  set(cmake_cxx_flags_debug "-g -wall -std=c++11")  set(google_mock gmock-1.6.0)  add_subdirectory(${google_mock})  include_directories(${project_source_dir}/${google_mock}/include) include_directories(${project_source_dir}/${google_mock}/gtest/include)  add_subdirectory(source)  enable_testing()  file(make_directory ${project_binary_dir}/tests)  set(testnames aircraft airport exception flightlevel           flightnumber pilotid registration remarks           route)  foreach(test ${testnames})     add_executable(tests/${test}.test tests/${test}test.cpp)     target_link_libraries(tests/${test}.test gmock_main)     add_test(${test} tests/${test}.test) endforeach(test) 

cmake generated eclipse project file, can used mingw. added few tests , code "source" folder tried build under eclipse, got many errors:

description resource    path    location    type make[2]: *** [cmakefiles/tests/aircraft.test.dir/tests/aircrafttest.cpp.obj] error 1                c/c++ problem make[1]: *** [cmakefiles/tests/aircraft.test.dir/all] error 2               c/c++ problem cmakefiles\tests\aircraft.test.dir/objects.a(aircrafttest.cpp.obj): bad reloc address 0x1b in section `.text$_zn7testing8internal6stringd1ev[__zn7testing8internal6stringd1ev]' fs_report@fs_reportworkspace            c/c++ problem make[1]: *** [gmock-1.6.0/gtest/cmakefiles/gtest.dir/all] error 2               c/c++ problem make[2]: *** [tests/aircraft.test.exe] error 1              c/c++ problem make[2]: *** [gmock-1.6.0/gtest/cmakefiles/gtest.dir/src/gtest-all.cc.obj] error 1              c/c++ problem undefined reference `aircraft::aircraft(std::string)'    fs_report@fs_reportworkspace        line 0  c/c++ problem undefined reference `aircraft::setaircraft(std::string)' fs_report@fs_reportworkspace        line 0  c/c++ problem recipe target 'cmakefiles/tests/aircraft.test.dir/all' failed   makefile2   /fs_report@fs_reportworkspace/cmakefiles    line 63 c/c++ problem undefined reference `aircraft::getaircraft()'    fs_report@fs_reportworkspace        line 0  c/c++ problem make: *** [all] error 2             c/c++ problem recipe target 'all' failed  makefile    /fs_report@fs_reportworkspace   line 84 c/c++ problem recipe target 'tests/aircraft.test.exe' failed  build.make  /fs_report@fs_reportworkspace/cmakefiles/tests/aircraft.test.dir    line 92 c/c++ problem 

classes in source files correct, because tested them earlier.

i tried add flags compilation , reinstall mingw, doesn't work.

this happens when symbols have incorrect __declspec (i.e. when bundling library sources in project or linking against static library need ensure symbols decorated __declspec(dllexport).

according gmock readme:

to compile *gtest* shared library, add    -dgtest_create_shared_library=1  compiler flags. [...]  compile *tests* use gtest shared library, add    -dgtest_linked_as_shared_library=1  compiler flags. 

so, depending on whether liking against gmock dll or compiling gmock sources project, need define corresponding macro. looks not linking against dll, need -dgtest_create_shared_library=1, since in gtest-port.h find

[...] # elif gtest_create_shared_library #  define gtest_api_ __declspec(dllexport) # endif [...] 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -