I've spent hours trying to figure out why I'm getting the following compiling error:
~/src/example/build $ make
-- Downloading GMock / GTest version 1.8.0 from git
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user/src/example/build
[ 5%] Performing update step for 'gmock'
[ 10%] Performing configure step for 'gmock'
-- gmock configure command succeeded. See also /home/user/src/example/build/gmock/src/gmock-stamp/gmock-configure-*.log
[ 15%] Performing build step for 'gmock'
-- gmock build command succeeded. See also /home/user/src/example/build/gmock/src/gmock-stamp/gmock-build-*.log
[ 20%] No install step for 'gmock'
[ 25%] Completed 'gmock'
[ 40%] Built target gmock
[ 75%] Built target project-app
Scanning dependencies of target step_definition_runner
[ 80%] Building CXX object Target/project/CMakeFiles/step_definition_runner.dir/features/step_definitions/App_Steps.cpp.o
In file included from /home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/internal/gtest-internal.h:40:0,
from /home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/gtest.h:58,
from /home/user/src/example/Target/project/features/step_definitions/App_Steps.cpp:1:
/home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/internal/gtest-port.h: In function ‘int testing::internal::posix::IsATTY(int)’:
/home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/internal/gtest-port.h:2341:45: error: ‘isatty’ was not declared in this scope
inline int IsATTY(int fd) { return isatty(fd); }
^
/home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/internal/gtest-port.h: In function ‘int testing::internal::posix::RmDir(const char*)’:
/home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/internal/gtest-port.h:2347:53: error: ‘rmdir’ was not declared in this scope
inline int RmDir(const char* dir) { return rmdir(dir); }
^
/home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/internal/gtest-port.h: In function ‘int testing::internal::posix::ChDir(const char*)’:
/home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/internal/gtest-port.h:2365:53: error: ‘chdir’ was not declared in this scope
inline int ChDir(const char* dir) { return chdir(dir); }
^
/home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/internal/gtest-port.h: In function ‘int testing::internal::posix::Read(int, void*, unsigned int)’:
/home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/internal/gtest-port.h:2379:46: error: ‘read’ was not declared in this scope
return static_cast<int>(read(fd, buf, count));
^
/home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/internal/gtest-port.h: In function ‘int testing::internal::posix::Write(int, const void*, unsigned int)’:
/home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/internal/gtest-port.h:2382:47: error: ‘write’ was not declared in this scope
return static_cast<int>(write(fd, buf, count));
^
/home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/internal/gtest-port.h: In function ‘int testing::internal::posix::Close(int)’:
/home/user/src/example/build/gmock/src/gmock/googletest/include/gtest/internal/gtest-port.h:2384:43: error: ‘close’ was not declared in this scope
inline int Close(int fd) { return close(fd); }
^
Target/project/CMakeFiles/step_definition_runner.dir/build.make:62: recipe for target 'Target/project/CMakeFiles/step_definition_runner.dir/features/step_definitions/App_Steps.cpp.o' failed
make[2]: *** [Target/project/CMakeFiles/step_definition_runner.dir/features/step_definitions/App_Steps.cpp.o] Error 1
CMakeFiles/Makefile2:164: recipe for target 'Target/project/CMakeFiles/step_definition_runner.dir/all' failed
make[1]: *** [Target/project/CMakeFiles/step_definition_runner.dir/all] Error 2
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2
I'm using the FindGMock.cmake from the cucumber-cpp project to handle the GTest dependency.
In my CMakeLists.txt file I have:
add_executable(step_definition_runner
features/step_definitions/App_Steps.cpp
)
target_include_directories(step_definition_runner
PRIVATE
${GTEST_INCLUDE_DIRS}
)
target_link_libraries(step_definition_runner project-app ${GTEST_LIBRARIES})
I've tried many things, but a couple of note:
Including unistd.h before I include gtest/gtest.h.
Force including unistd.h inside gtest/gtest.h and gtest/internal/gtest-port.h.
Is there something obvious I'm missing?
It seems like you are not on windows OS.
These functions are allowed only for windows
Look for below content in
https://github.com/google/googletest/blob/master/googletest/include/gtest/internal/gtest-port.h
402 // Brings in definitions for functions used in the testing::internal::posix
403 // namespace (read, write, close, chdir, isatty, stat). We do not currently
404 // use them on Windows Mobile.
405 #if GTEST_OS_WINDOWS
406 # if !GTEST_OS_WINDOWS_MOBILE
407 # include <direct.h>
408 # include <io.h>
409 # endif
Related
What I want to do
I want to build a ROOT class "RooUnfold" in Mac.
Question
How can I solve linker errors (ld: library not found for -lgcov clang: error: linker command failed with exit code 1 (use -v to see invocation)) which occurs when I tried to build RooUnfold using cmake?
What I did
(1) I installed ROOT on my Mac. It successfully works.
(2) I downloaded and unzipped "RooUnfold-master.zip" from a web cite(https://gitlab.cern.ch/RooUnfold/RooUnfold).
(3) I tried to build RooUnfold following the instructions on the web cite as following :
cd RooUnfold-master
mkdir build
cd build
cmake ..
make -j4
cd ..
source build/setup.sh
(4) However, it was failed when I tried make -j4 with following output :
$ cd RooUnfold-master
$ mkdir build
$ cd build
$ cmake ..
CMake Deprecation Warning at CMakeLists.txt:10 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
Setup using plain ROOT
Doxygen build started
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/XXXXXX/RooUnfold-master/build
$ make -j4
[ 2%] Generating G__RooUnfold.cxx, libRooUnfold_rdict.pcm, libRooUnfold.rootmap
Scanning dependencies of target RooUnfold
[ 9%] Building CXX object CMakeFiles/RooUnfold.dir/src/RooUnfoldBayes.o
[ 9%] Building CXX object CMakeFiles/RooUnfold.dir/src/RooUnfold.o
[ 9%] Building CXX object CMakeFiles/RooUnfold.dir/src/RooFitUnfold.o
[ 12%] Building CXX object CMakeFiles/RooUnfold.dir/src/RooUnfoldBinByBin.o
In file included from /Users/XXXXXX/RooUnfold-master/src/RooUnfoldBinByBin.cxx:8:
/Users/XXXXXX/RooUnfold-master/src/RooUnfoldBinByBin.h:44:3: warning: 'CheckTObjectHashConsistency' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
ClassDefT (RooUnfoldBinByBinT, 1) // Bin-by-bin unfolding
^
/opt/homebrew/Cellar/root/6.26.04_1/include/root/Rtypes.h:392:4: note: expanded from macro 'ClassDefT'
_ClassDefOutline_(name,id,virtual,) \
^
/opt/homebrew/Cellar/root/6.26.04_1/include/root/Rtypes.h:300:4: note: expanded from macro '_ClassDefOutline_'
_ClassDefBase_(name,id, virtual_keyword, overrd) \
^
(a lot of "override" errors)
97 warnings generated.
[ 63%] Linking CXX shared library libRooUnfold.dylib
[ 63%] Built target RooUnfold
[ 73%] Building CXX object CMakeFiles/RooUnfoldTest3D.dir/test/src/RooUnfoldTest3D.o
[ 73%] Building CXX object test/CMakeFiles/RooUnfoldTests.dir/src/generate_test.o
[ 73%] Building CXX object CMakeFiles/RooUnfoldTest2D.dir/test/src/RooUnfoldTest2D.o
[ 73%] Building CXX object CMakeFiles/RooUnfoldTest.dir/test/src/RooUnfoldTest.o
[ 75%] Building CXX object test/CMakeFiles/RooUnfoldTests.dir/src/response_test.o
[ 78%] Linking CXX executable RooUnfoldTest
ld: library not found for -lgcov
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [RooUnfoldTest] Error 1
make[1]: *** [CMakeFiles/RooUnfoldTest.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 80%] Building CXX object test/CMakeFiles/RooUnfoldTests.dir/src/bayes_test.o
[ 82%] Linking CXX executable RooUnfoldTest2D
ld: library not found for -lgcov
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [RooUnfoldTest2D] Error 1
make[1]: *** [CMakeFiles/RooUnfoldTest2D.dir/all] Error 2
[ 85%] Linking CXX executable RooUnfoldTest3D
[ 87%] Building CXX object test/CMakeFiles/RooUnfoldTests.dir/src/RooUnfold_unit_tests.o
ld: library not found for -lgcov
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [RooUnfoldTest3D] Error 1
make[1]: *** [CMakeFiles/RooUnfoldTest3D.dir/all] Error 2
In file included from /Users/XXXXXX/RooUnfold-master/test/src/bayes_test.cxx:13:
/Users/XXXXXX/RooUnfold-master/src/RooUnfoldBayes.h:45:17: warning: 'SetRegParm' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
virtual void SetRegParm (Double_t parm);
^
/Users/XXXXXX/RooUnfold-master/test/src/bayes_test.cxx:31:20: note: in instantiation of template class 'RooUnfoldBayesT<TH1, TH2>' requested here
RooUnfoldBayes unfold(&response, h_meas, 4);
^
/Users/XXXXXX/RooUnfold-master/src/RooUnfold.h:115:22: note: overridden virtual function is here
virtual void SetRegParm (Double_t parm);
^
In file included from /Users/XXXXXX/RooUnfold-master/test/src/bayes_test.cxx:13:
/Users/XXXXXX/RooUnfold-master/src/RooUnfoldBayes.h:46:18: warning: 'GetRegParm' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
virtual double GetRegParm() const;
^
/Users/XXXXXX/RooUnfold-master/src/RooUnfold.h:116:22: note: overridden virtual function is here
virtual Double_t GetRegParm() const; // Get Regularisation Parameter
^
In file included from /Users/XXXXXX/RooUnfold-master/test/src/bayes_test.cxx:13:
/Users/XXXXXX/RooUnfold-master/src/RooUnfoldBayes.h:47:16: warning: 'Reset' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
virtual void Reset();
^
/Users/XXXXXX/RooUnfold-master/src/RooUnfold.h:74:16: note: overridden virtual function is here
virtual void Reset ();
^
In file included from /Users/XXXXXX/RooUnfold-master/test/src/bayes_test.cxx:13:
/Users/XXXXXX/RooUnfold-master/src/RooUnfoldBayes.h:48:16: warning: 'Print' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
virtual void Print (Option_t* option= "") const;
^
/Users/XXXXXX/RooUnfold-master/src/RooUnfold.h:129:8: note: overridden virtual function is here
void Print(Option_t* opt="") const;
^
/Users/XXXXXX/RooUnfold-master/test/src/RooUnfold_unit_tests.cxx:29:62: warning: format specifies type 'unsigned int' but the argument has type 'std::vector<float>::size_type' (aka 'unsigned long') [-Wformat]
check(n==r.size(), "error in bayes: %d bins is not %u",n,r.size());
~~ ^~~~~~~~
%lu
/Users/XXXXXX/RooUnfold-master/test/src/dbg.h:30:18: note: expanded from macro 'check'
log_err(M, ##__VA_ARGS__); errno=0; goto error; }
~ ^~~~~~~~~~~
/Users/XXXXXX/RooUnfold-master/test/src/dbg.h:20:26: note: expanded from macro 'log_err'
clean_errno(), ##__VA_ARGS__)
^~~~~~~~~~~
4 warnings generated.
1 warning generated.
[ 90%] Linking CXX static library libRooUnfoldTests.a
[ 90%] Built target RooUnfoldTests
make: *** [all] Error 2
(5) I think the linker errors such as ld: library not found for -lgcov clang: error: linker command failed with exit code 1 (use -v to see invocation) are fatal, but I could not solve them.
Environment
Mac OS : Monterey ver. 12.3
chip : Apple M1 Pro
ROOT : ver. 6.26
$ root --version
ROOT Version: 6.26/04
Built for macosxarm64 on Jun 07 2022, 16:01:16
From tags/v6-26-04#v6-26-04
gcc : ver. 13.1.6
$ gcc --version
Apple clang version 13.1.6 (clang-1316.0.21.2)
Target: arm64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
cmake : ver. 3.22.3
$ cmake --version
cmake version 3.22.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
I think the problem lies in the CMakeLists.txt file. How have to link it. how you would do that is as follows:
...
find_package(ROOT)
...
target_link_libraries(${ROOT_LIBRARIES})
...
I built RooUnfold successfully by using another CMakeFile.txt at https://gitlab.cern.ch/RooUnfold/RooUnfold/-/tree/CMakeLists-fix.
I have not understood the difference completely yet.
However, it may be better to install not from "master", but from "CMakeLists-fix" for Mac users who want to use RooUnfold.
I am trying to install a package called Siconos, which uses python and its libraries, and also C++ and other libraries such as oce and occ.
It is installed correctly but when I run a C++ code using Siconos it is giving me the follwoing Boost error,
|===========================================================|
| Siconos software, version 4.4.0 - Copyright 2021 INRIA |
| |
| Free software under Apache 2.0 License. |
|===========================================================|
[ Generate CMakeLists.txt file in /scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/.siconos ]
[------------------- Configure project (cmake) --------------------]
-- Boost version: 1.65.1
-- Configuring done
-- Generating done
-- Build files have been written to: /scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/.siconos
[---------------------- Build project (make) ----------------------]
[ 33%] Built target BallPlugin
Scanning dependencies of target BouncingBallTS
[ 50%] Building CXX object CMakeFiles/BouncingBallTS.dir/scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/BouncingBallTS.cpp.o
/scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/BouncingBallTS.cpp: In function ‘int main(int, char**)’:
/scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/BouncingBallTS.cpp:147:12: error: ‘progress_display’ is not a member of ‘boost’
boost::progress_display show_progress(N);
^~~~~~~~~~~~~~~~
/scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/BouncingBallTS.cpp:149:12: error: ‘timer’ is not a member of ‘boost’
boost::timer time;
^~~~~
/scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/BouncingBallTS.cpp:150:10: error: request for member ‘restart’ in ‘time’, which is of non-class type ‘time_t(time_t*) noexcept {aka long int(long int*) noexcept}’
time.restart();
^~~~~~~
/scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/BouncingBallTS.cpp:162:9: error: ‘show_progress’ was not declared in this scope
++show_progress;
^~~~~~~~~~~~~
/scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/BouncingBallTS.cpp:167:41: error: request for member ‘elapsed’ in ‘time’, which is of non-class type ‘time_t(time_t*) noexcept {aka long int(long int*) noexcept}’
cout << "Computation Time " << time.elapsed() << endl;
^~~~~~~
/scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/BouncingBallTS.cpp:180:10: error: ‘SiconosException’ does not name a type; did you mean ‘SiconosVector’?
catch (SiconosException& e)
^~~~~~~~~~~~~~~~
SiconosVector
/scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/BouncingBallTS.cpp:182:13: error: ‘e’ was not declared in this scope
cerr << e.report() << endl;
^
CMakeFiles/BouncingBallTS.dir/build.make:62: recipe for target 'CMakeFiles/BouncingBallTS.dir/scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/BouncingBallTS.cpp.o' failed
make[2]: *** [CMakeFiles/BouncingBallTS.dir/scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/BouncingBallTS.cpp.o] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/BouncingBallTS.dir/all' failed
make[1]: *** [CMakeFiles/BouncingBallTS.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
Traceback (most recent call last):
File "/usr/local/bin/siconos", line 826, in <module>
main()
File "/usr/local/bin/siconos", line 151, in main
build_project(args)
File "/usr/local/bin/siconos", line 768, in build_project
run_command(cmake_build_command, args.quiet)
File "/usr/local/bin/siconos", line 799, in run_command
subprocess.run(command, check=True, **extra_args)
File "/usr/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['cmake', '--build', '/scratch/rsayoud/Documents/siconos-tutorials/examples/mechanics/BouncingBall/.siconos', '--target', 'install', '--']' returned non-zero exit status 2.
Any suggestions ?
It's most likely missing the necessary #include file.
Boost files and others may include other files, but are unspecified as to what else they include (commonly referred to as "dragging in"). This means that if you forget to #include something, it might work anyway because it was nested inside another header. But after an update, or under a different configuration, that no longer works because the internal include files have changed.
You should check the Boost docs for the correct include file for that symbol, and add it to the top of whichever file contains the error. This may be necessary for several files.
i'm trying to use microsoft SEAL library for homomorphic encryption and following the steps from the below link https://github.com/cyberweapons/SEAL/blob/master/INSTALL.txt
when i use command cmake .
terminal shows below result
-- SEAL detected (version 2.3.1)
-- SEAL build type: Release
-- SEAL debug mode: OFF
-- SEAL using Microsoft GSL: OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ravindra/Desktop/../../MiSEAL/SEAL/SEALExamples
after that when i give make command it should generate a file main.cpp.o instead it is giving the following errors.
[ 50%] Building CXX object CMakeFiles/sealexamples.dir/main.cpp.o
In file included from /usr/local/include/seal/util/mempool.h:12:0,
from /usr/local/include/seal/memorypoolhandle.h:6,
from /usr/local/include/seal/biguint.h:6,
from /usr/local/include/seal/bigpoly.h:9,
from /usr/local/include/seal/seal.h:3,
from /home/ravindra/Desktop/SakhaProjects/S20_AI/MiSEAL/SEAL/SEALExamples/main.cpp:12:
/usr/local/include/seal/util/locks.h:12:45: error: ‘shared_mutex’ is not a member of ‘std’
using ReaderLock = std::shared_lock<std::shared_mutex>;
^~~
/usr/local/include/seal/util/locks.h:12:45: error: ‘shared_mutex’ is not a member of ‘std’
/usr/local/include/seal/util/locks.h:12:62: error: template argument 1 is invalid
using ReaderLock = std::shared_lock<std::shared_mutex>;
^
/usr/local/include/seal/util/locks.h:14:45: error: ‘shared_mutex’ is not a member of ‘std’
using WriterLock = std::unique_lock<std::shared_mutex>;
^~~
/usr/local/include/seal/util/locks.h:14:45: error: ‘shared_mutex’ is not a member of ‘std’
/usr/local/include/seal/util/locks.h:14:62: error: template argument 1 is invalid
using WriterLock = std::unique_lock<std::shared_mutex>;
^
/usr/local/include/seal/util/locks.h:21:20: error: ‘ReaderLock’ does not name a type
inline ReaderLock acquire_read()
^~~~~~~~~~
/usr/local/include/seal/util/locks.h:26:20: error: ‘WriterLock’ does not name a type
inline WriterLock acquire_write()
^~~~~~~~~~
/usr/local/include/seal/util/locks.h:31:20: error: ‘ReaderLock’ does not name a type
inline ReaderLock try_acquire_read()
^~~~~~~~~~
/usr/local/include/seal/util/locks.h:36:20: error: ‘WriterLock’ does not name a type
inline WriterLock try_acquire_write()
^~~~~~~~~~
/usr/local/include/seal/util/locks.h:46:18: error: ‘shared_mutex’ in namespace ‘std’ does not name a type
std::shared_mutex rw_lock_mutex_;
^~~~~~~~~~~~
In file included from /usr/local/include/seal/memorypoolhandle.h:6:0,
from /usr/local/include/seal/biguint.h:6,
from /usr/local/include/seal/bigpoly.h:9,
from /usr/local/include/seal/seal.h:3,
from /home/ravindra/Desktop/SakhaProjects/S20_AI/MiSEAL/SEAL/SEALExamples/main.cpp:12:
/usr/local/include/seal/util/mempool.h: In member function ‘virtual int64_t seal::util::MemoryPoolMT::pool_count() const’:
/usr/local/include/seal/util/mempool.h:561:17: error: ‘ReaderLock’ was not declared in this scope
ReaderLock lock(pools_locker_.acquire_read());
^~~~~~~~~~
CMakeFiles/sealexamples.dir/build.make:62: recipe for target 'CMakeFiles/sealexamples.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/sealexamples.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/sealexamples.dir/all' failed
make[1]: *** [CMakeFiles/sealexamples.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
i am new to SEAL library also i am a beginner to c++ programming, please someone help me to fix this issues.
Hi i found the solution,
i have included following commands in CMakeLists.txt file continued with the steps
`
# Below is TFHE START
export TFHE_PREFIX=/usr/local
export CPLUS_INCLUDE_PATH=${TFHE_PREFIX}/include:${CPLUS_INCLUDE_PATH}
export C_INCLUDE_PATH=${TFHE_PREFIX}/include:${C_INCLUDE_PATH}
export LIBRARY_PATH=${TFHE_PREFIX}/lib:${LIBRARY_PATH}
export LD_LIBRARY_PATH=${TFHE_PREFIX}/lib:${LD_LIBRARY_PATH}
# Below is TFHE END
`
First I am not very familiar with C++ compile process, but I have to compile the emgucv repository on Ubuntu 18.04. I follow the instruction and try to figure out things by searching through Stack Exchange.
I got every dependencies setup, then the only file I need to execute is this one.
Although it is written for 16.04, seems to work for 18.04, but the compilation throws an error. It says _MAX_DRIVE, _MAX_DIR, _MAX_PATH, DWORD, errno_t, etc. are not declared. As suggested by the comment, they are Windows-specific. The error occurs in this file. And the module that contains this file is this.
My question is how to get this compiled on Ubuntu 18.04? I am very confused, since Emgucv says they support Linux (instruction at the end), and I believe others could have successfully compiled it on their Linux. I attempted to replace those constants _MAX_DRIVE, _MAX_DIR, _MAX_PATH by just numbers, the DWORD by unsigned long, and errno_t by int, then it says now GetModuleFileName, _splitpath_s are not declared. I don't know how to do. Is there anyway for this to work for Ubuntu?
[ 74%] Building CXX object Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/tesseract-ocr.git/src/ccutil/mainblk.cpp.o
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp: In member function ‘void tesseract::CCUtil::main_setup(const char*, const char*)’:
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:77:16: error: ‘_MAX_DRIVE’ was not declared in this scope
char drive[_MAX_DRIVE];
^~~~~~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:78:14: error: ‘_MAX_DIR’ was not declared in this scope
char dir[_MAX_DIR];
^~~~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:79:15: error: ‘_MAX_PATH’ was not declared in this scope
char path[_MAX_PATH];
^~~~~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:83:5: error: ‘DWORD’ was not declared in this scope
DWORD length = GetModuleFileName(nullptr, path, sizeof(path));
^~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:85:9: error: ‘length’ was not declared in this scope
if (length > 0 && length < sizeof(path)) {
^~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:85:39: error: ‘path’ was not declared in this scope
if (length > 0 && length < sizeof(path)) {
^~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:86:7: error: ‘errno_t’ was not declared in this scope
errno_t result = _splitpath_s(path, drive, sizeof(drive),
^~~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:88:11: error: ‘result’ was not declared in this scope
if (result == ERANGE) {
^~~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:92:17: error: ‘drive’ was not declared in this scope
datadir = drive;
^~~~~
/media/philips_cpm/data1/emgucv/Emgu.CV.Extern/tesseract/libtesseract/tesseract-ocr.git/src/ccutil/mainblk.cpp:93:18: error: ‘dir’ was not declared in this scope
datadir += dir;
^~~
Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/build.make:302: recipe for target 'Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/tesseract-ocr.git/src/ccutil/mainblk.cpp.o' failed
make[2]: *** [Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/tesseract-ocr.git/src/ccutil/mainblk.cpp.o] Error 1
CMakeFiles/Makefile2:5929: recipe for target 'Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/all' failed
make[1]: *** [Emgu.CV.Extern/tesseract/libtesseract/CMakeFiles/tesseract_ccutil.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
Emgu CV compile manual for Ubuntu
The commands are summarized below
git clone https://github.com/emgucv/emgucv emgucv
cd emgucv
git submodule update --init --recursive
cd platforms/ubuntu/16.04
./apt_install_dependency.sh
./cmake_configure.sh
I'm tring to conform a part of matlab source to C++. The matlab source calls a matlab lib named Manopt for params optimizing, So I found a lib in C++ named ROPTLIB(http://www.math.fsu.edu/ROPTLIB/) to realize the same optimization as Manopt.
The problem occured when I download ROPTLIB and try to run the example demo in ROPTLIB user manual. I wrote a CMakeLists.txt(as follow) to compile the lib source code, for there is no compiling tools in lib diretory(except matlab script, but I want the lib run in pure C++ environment in my ubuntu 14.04LTS). The package of lapack and blas are also link to project as you can see in CMakelists.txt.
I try to search the Problem both in google and other forums, but no one can help me. If you have any experience for debug locale_facets_nonio.tcc:918:22: error: expected unqualified-id before or ROPTLIB, printing it blow mat help me.
CmakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
SET(ProjectName TestProductExample)
PROJECT(${ProjectName})
FILE(GLOB_RECURSE all_files
"${CMAKE_CURRENT_SOURCE_DIR}/Solvers/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Problems/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Others/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Manifolds/*.cpp"
)
INCLUDE_DIRECTORIES(
"${CMAKE_CURRENT_SOURCE_DIR}/Solvers/"
"${CMAKE_CURRENT_SOURCE_DIR}/Problems/"
"${CMAKE_CURRENT_SOURCE_DIR}/Problems/StieSumBrockett/"
"${CMAKE_CURRENT_SOURCE_DIR}/Others/"
"${CMAKE_CURRENT_SOURCE_DIR}/Manifolds/"
"${CMAKE_CURRENT_SOURCE_DIR}/Manifolds/Stiefel/"
"${CMAKE_CURRENT_SOURCE_DIR}/Manifolds/Euclidean/"
"${CMAKE_CURRENT_SOURCE_DIR}/blas/"
"${CMAKE_CURRENT_SOURCE_DIR}/lapack/"
)
message(STATUS "add include_directories " ${INCLUDE_DIRECTORIES})
if(${CMAKE_COMPILER_IS_GNUCC})
message (STATUS "add c++11 flags")
add_definitions(-Wall -s -std=c++11 )
endif()
set(LIB "${CMAKE_CURRENT_SOURCE_DIR}/lib/;${LIB}")
message (STATUS "blas and lapack lib is in ${LIB}")
add_executable(${ProjectName} ${CMAKE_CURRENT_SOURCE_DIR}/test/TestProductExample.cpp ${all_files})
link_directories({${LIB}})
target_link_libraries(${ProjectName} lapack_LINUX.a blas_LINUX.a tmglib_LINUX.a)
message (STATUS "CMAKE_C_COMPILER is ${CMAKE_C_COMPILER}, CMAKE_CXX_COMPILER is ${CMAKE_CXX_COMPILER}")
message (STATUS "CMAKE_COMPILER_IS_GNUCC is ${CMAKE_COMPILER_IS_GNUCC}")`
error log:
[ 1%] Building CXX object CMakeFiles/TestProductExample.dir/test/TestProductExample.cpp.o
In file included from /usr/include/c++/4.7/bits/locale_facets_nonio.h:1903:0,
from /usr/include/c++/4.7/locale:43,
from /usr/include/c++/4.7/iomanip:45,
from /home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Manifolds/Manifold.h:23,
from /home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Problems/Problem.h:16,
from /home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/test/TestProductExample.cpp:20:
/usr/include/c++/4.7/bits/locale_facets_nonio.tcc: In member function ‘_InIter std::time_get<_CharT, _InIter>::_M_extract_name(std::time_get<_CharT, _InIter>::iter_type, std::time_get<_CharT, _InIter>::iter_type, int&, const _CharT**, std::size_t, std::ios_base&, std::ios_base::iostate&) const’:
/usr/include/c++/4.7/bits/locale_facets_nonio.tcc:918:22: error: expected unqualified-id before ‘(’ token
In file included from /home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/test/TestProductExample.cpp:15:0:
/home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Others/randgen.h: At global scope:
/home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Others/randgen.h:69:13: warning: ‘void next_state()’ declared ‘static’ but never defined [-Wunused-function]
/home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Others/randgen.h:64:22: warning: ‘randgen::state’ defined but not used [-Wunused-variable]
/home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Others/randgen.h:65:12: warning: ‘randgen::left’ defined but not used [-Wunused-variable]
/home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Others/randgen.h:66:12: warning: ‘randgen::initf’ defined but not used [-Wunused-variable]
/home/wangyuanjiang/Documents/software/ROPTLIB_2016-04-29_CPP/Others/randgen.h:67:23: warning: ‘randgen::next’ defined but not used [-Wunused-variable]
make[2]: *** [CMakeFiles/TestProductExample.dir/test/TestProductExample.cpp.o] Error 1
make[1]: *** [CMakeFiles/TestProductExample.dir/all] Error 2
make: *** [all] Error 2