I tried to build Boost from source for 64bit using MinGW (x64) but failed when creating the bjam.exe. Any pointer to help is appreciated. Thanks.
Package: Boost 1.52.0 (download from sourceforge, C:\BoostSrc)
Package: MinGW-w64 (4.7.2-x64 rubenvb, C:\MinGW\rubenvb-4.7.2-64)
I created the following batch file to ensure repeatable building, but things got wrong. I cannot build the bjam.exe with supplied batch file. I'm not using the supplied "bootstrap.bat" as the non-standard installation path of MinGW (I have multiple mingw sets), and I have no MSVC installed in my machine
SET BOOST_VER=boost_1_52_0
SET PATH_MINGW=C:\MinGW\rubenvb-4.7.2-64
SET PATH_BJAM=%~dp0\%BOOST_VER%\tools\build\v2\engine
SET PATH="%PATH_MINGW%\bin"
PUSHD "%PATH_BJAM%"
REM check path
mingw32-make -version
REM error below
build.bat mingw --toolset-root=%PATH_MINGW% --show-locate-target
SET PATH=%OPATH%
POPD
REM ... some more ...
Error message
gcc: error: CreateProcess: No such file or directory
When I type the command directly from command prompt (set the path, go to location and invoke build.bat), it goes smoothly (with warnings which i think can be ignored)
This may solve your issue, but even if it doesn't it's a good idea to change it anyways.
Use a different variable name other than PATH as this is a built in and important windows environment variable, which MINGW may be relying on.
After digging into build.bat located at BOOST_ROOT\tools\build\v2\engine, when supplying "mingw" as the toolset, the script by-passed the "guessing toolset" step and failed to define the variable "BOOST_JAM_TOOLSET_ROOT", leaving calls to gcc-related executables failed.
Now I changed the batch as follow
PUSHD "%PATH_BJAM%"
SET "PATH=%PATH_MINGW%\bin"
REM add the line below
SET "BOOST_JAM_TOOLSET_ROOT=%PATH_MINGW%\"
build.bat mingw --show-locate-target
SET PATH=%OPATH%
I manually set the BOOST_JAM_TOOLSET_ROOT variable from external batch file and this worked fine. Beware of the ending "\" character, as the build.bat inside append the path variable as this:
set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
Thanks very much for any comments and suggestions.
Related
I am trying to use opencv in a project, and am running into problems 'installing' it. I have extracted the opencv files and have created a small test program:
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
int main(int argc, char **argv){
cv::Mat im=cv::imread((argc==2)? argv[1]: "testing.jpg",1);
if (im.empty()){
std::cout << "Cannot open image." << std::endl;
} else {
cv::imshow("image",im);
cv::waitKey(0);
}
return 0;
}
To compile the program I have used the command below:
g++ -I"../../PortableGit/opt/opencv/build/include/" -L"../../PortableGit/opt/opencv/build/x64/vc15/lib" main.cpp -lopencv_core -lopencv_highgui -o main
I get the errors below:
In file included from ../../PortableGit/opt/opencv/build/include/opencv2/core.hpp:3293:0,
from ../../PortableGit/opt/opencv/build/include/opencv2/highgui.hpp:46,
from ../../PortableGit/opt/opencv/build/include/opencv2/highgui/highgui.hpp:48,
from main.cpp:1:
../../PortableGit/opt/opencv/build/include/opencv2/core/utility.hpp:714:14: error: 'recursive_mutex' in namespace 'std' does not name
a type
typedef std::recursive_mutex Mutex;
^~~~~~~~~~~~~~~
../../PortableGit/opt/opencv/build/include/opencv2/core/utility.hpp:715:25: error: 'Mutex' is not a member of 'cv'
typedef std::lock_guard<cv::Mutex> AutoLock;
^~
../../PortableGit/opt/opencv/build/include/opencv2/core/utility.hpp:715:25: error: 'Mutex' is not a member of 'cv'
../../PortableGit/opt/opencv/build/include/opencv2/core/utility.hpp:715:34: error: template argument 1 is invalid
typedef std::lock_guard<cv::Mutex> AutoLock;
I believe that it has something to do with mingw binaries no longer being included with opencv. I am missing the opencv/build/x86/mingw directory.
My questions are:
How do I 'install' opencv and use it without also installing some sort of IDE and/or CMake? (I prefer to use vim and the command line.)
Once installed, what command do I use to compile and link a program with opencv?
Any help is appreciated.
Edit:
This appears to be a problem with GCC's implementation of threads on windows. Using mingw-w64 instead of mingw fixed the std::recursive_mutex issue, but now the linker cannot find the proper files.
/i686-w64-mingw32/bin/ld.exe: cannot find -lopencv_core
/i686-w64-mingw32/bin/ld.exe: cannot find -lopencv_highgui
After quite a bit of trying things out, this is what I got to work. Oddly, following the LINUX guide to install opencv worked better than the WINDOWS guide, even though I have a windows computer.
Guide to Installing OpenCV on Windows Without VS
Heads-up: This is a multi-step process, 3 separate tools are required. Be prepared for this to take a while.
Part 1: Get everything ready
Download MinGW-w64.
On the downloads page, click on the "MinGW-w64-builds" option. Do not click on the "win-builds" option.
The reason MinGW-w64 has to be used is because it is a newer version of the MinGW compiler suit that has been improved for windows. This means that it supports the posix thread system, where as the standard MinGW compiler only supports the win32 thread system. OpenCV relies on the posix thread system, necessitating the MinGW-w64 compiler.
Extract the MinGW-w64 zip folder to a directory. In my case its PortableGit/opt/MinGW-w64
At this point, you can add the MingGW-w64/mingw32/bin folder to your path. (Assuming that this won't cause any conflicts.) If you do so, you will not have to constantly specify the g++ executable directory to run it. This is up to your discretion.
Download an opencv release.
Do not download the package for windows, click the button that says "sources"
Extract the opencv sources zip folder to a directory. In my case its PortableGit/opt/opencv-4.3.0
Also download the opencv_contrib source files directly from the repository.
Extract that folder and place it inside the top level opencv folder: PortableGit/opt/opencv-4.3.0/opencv_contrib in my case.
Download CMake.
I downloaded the zip folder, but you can download the installer if you wish.
Extract the CMake zip folder if you downloaded that, or run the installer. I put my CMake folder here: PortableGit/opt/cmake-3.17.1-win32-x86
At this point, you can add the cmake-3.17.1-win32-x86/bin folder to your path. (Assuming that this won't cause any conflicts.) If you do so, you will not have to constantly specify the cmake executable directory to run it. This is up to your discretion.
Part 2: Build OpenCV
Navigate to the opencv directory and create a build folder and cd into it.
mkdir build && cd build
Run the following export commands.
export CC=/PortableGit/MinGW-w64/mingw32/bin/gcc.exe
export CXX=/PortableGit/MinGW-w64/mingw32/bin/g++.exe
This is to make sure the next cmake command uses the proper compilers.
Run the following cmake command from within that folder:
PortableGit/opt/cmake-3.17.1-win32-x86/cmake.exe -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DOPENCV_VS_VERSIONINFO_SKIP=1 -DOPENCV_EXTRA_MODULES_PATH="/PortableGit/opt/opencv-4.3.0/opencv_contrib/modules/" ..
The -G flag specifies that we are creating build files for the MinGW compiler
The -DCMAKE_BUILD_TYPE=Release specifies that we are building the release version of opencv and not the debug version.
The DOPENCV_EXTRA_MODULES_PATH needs to be set to the modules folder inside the opencv_contrib folder. For me it was PortableGit/opt/opencv-4.3.0/opencv_contrib/modules
The DOPENCV_VS_VERSIONINFO_SKIP specifies to not include version info. If not set, the compiler will throw an error complaining about not having version files. (Shown below for reference.)
gcc: error: long: No such file or directory
mingw32-make[2]: *** [modules\core\CMakeFiles\opencv_core.dir\build.make:1341:
modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj] Error 1
If successful, the cmake command will finish like this:
Now run this command, again from the build folder: /PortableGit/opt/MinGW-w64/mingw32/bin/mingw32-make.exe -j7
mingw32-make.exe is the windows equivalent of the Linux make command.
The -j7 option run the process with a maximum of 7 threads.
This will take a while! It took my laptop ~20 minutes to complete
If the make command ends in an error, make sure to reset your build directory before continuing any troubleshooting. This is done through this series of commands
rm -rf build
mkdir build
cd build
Part 3: Using OpenCV
To use the opencv library that you just compiled in a project of your own, compile the project with these flags from your projects main directory.
Remember that your compiler now has to be set to the mingw-w64 compiler for opencv support.
I added indentation and newlines for readability, but when entering this in the terminal do not include the newlines or indents.
The number at the end of the linker options may change depending on the version of opencv you downloaded. I downloaded opencv-4.3.0, making my number 430, but yours may be different.
PortableGit/opt/MinGW-w64/bin/g++.exe
-I../../PortableGit/opt/opencv-4.3.0/include/
-I../../PortableGit/opt/opencv-4.3.0/build/
-I../../PortableGit/opt/opencv-4.3.0/modules/core/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/calib3d/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/dnn/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/features2d/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/flann/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/gapi/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/highgui/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/imgcodecs/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/imgproc/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/ml/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/objdetect/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/photo/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/stitching/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/ts/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/video/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/videoio/include/
-I../../PortableGit/opt/opencv-4.3.0/modules/world/include/
-L../../PortableGit/opt/opencv-4.3.0/build/lib/
*.hpp
*.cpp
-lopencv_calib3d430
-lopencv_core430
-lopencv_dnn430
-lopencv_features2d430
-lopencv_flann430
-lopencv_highgui430
-lopencv_imgcodecs430
-lopencv_imgproc430
-lopencv_ml430
-lopencv_objdetect430
-lopencv_photo430
-lopencv_stitching430
-lopencv_video430
-lopencv_videoio430
-o
main
Or you could download VS. Up to you. Hope this helps.
Correction for JackCamichael's answer
those 2 commands won't work in Windows
export CC=/PortableGit/MinGW-w64/mingw32/bin/gcc.exe
export CXX=/PortableGit/MinGW-w64/mingw32/bin/g++.exe
This should be
setx -m CC C:\msys64\mingw64\bin\gcc.exe
setx -m CXX C:\msys64\mingw64\bin\g++.exe
C:\msys64\mingw64\bin is mingw64 path on my machine
I am downloading this code from GitHub (subdivision-regression), and am getting stuck following the instructions:
To build doosabin_regression:
Run CMake with an out of source build.
Set COMMON_CPP_INCLUDE_DIR to the full path to rstebbing/common/cpp.
Set DOOSABIN_INCLUDE_DIR to the full path to rstebbing/subdivision/cpp/doosabin/include.
Set Ceres_DIR to the directory containing CeresConfig.cmake.
Set GFLAGS_INCLUDE_DIR, GFLAGS_LIBRARY and RAPID_JSON_INCLUDE_DIR. (Add -std=c++11 to CMAKE_CXX_FLAGS if compiling with gcc.)
Configure.
Build.
I have edited the CMakeLists.txt file to put the correct paths in. I then created a new directory called subdivision-regression-bin and ran:
cmake ../subdivision-regression/src
It completes this and displays:
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hert5584/RStebbing/subdivision-regression-bin
However, when I try and run the example code, it cannot find the files listed in CMakeLists.txt (I know they are the right paths as otherwise CMake does not run).
I have tried running:
sudo make install
But get the following error:
make: *** No rule to make target 'install'. Stop.
Any ideas why this isn't working? Have the above steps Configured and Built the files?
The ordered CMake idiom to understand is:
The Configure step
The Generate step (This is often subsumed in the Configure step, and not mentioned explicitly, as in this case.)
The Build step (in which you actually compile/link your code into libraries/executables)
Take a look at this resource for information about the configure and generate stages.
You didn't appear to perform the steps to set CMake cache variables. For these you have to use CMake command line options (-D specifically). So run CMake as something like this instead to set all six variables:
cmake -DCOMMON_CPP_INCLUDE_DIR=/rstebbing/common/cp -DDOOSABIN_INCLUDE_DIR=...[More CMake Cache variables]... ../subdivision-regression/src
For building, try just running make without sudo or install:
make
I've found the lightweight DSP c library - Soundpipe.
I want to use some filters from it. I do not really need binary files, but the problem is that the repository doesn't have its main header file - soundpipe.h. As I understand, this is because the library uses specific modules ported from Csound and FAUST languages. Also the repository's readme doesn't have installation guide for Windows. It says:
By default, Soundpipe needs libsndfile, and a standard build
environment. Other modules that use other external libraries will need
to be explicitly compiled by modifying config.mk (note: but the Makefile's folder doesn't contain config.mk, there is only config.def.mk)
To compile:
make
sudo make install
Ok, I've downloaded and installed libsndfile.
Then I have tried to use MSVC's nmake - it doesn't work:
makefile(7) : fatal error U1036: syntax error : too many names to left of '='
Stop.
Here is the beginning of the makefile:
> .PHONY: all clean install docs bootstrap
>
> default: all
>
> VERSION = 1.5.0
>
> INTERMEDIATES_PREFIX ?= . PREFIX ?= /usr/local
> ...
After that I've downloaded MinGW, mingw32-make result:
config.mk: No such file or directory
mingw32-make: *** No rule to make target 'config.def.mk', needed by 'config.mk'. Stop.
Ok, when I try to run the configure command, it doesn't work on my Win7 x 64 (sh: ./configure: No such file or directory, etc...)
I have the paths in mt system path variable:
C:\MinGW\bin;C:\MinGW\msys\1.0\bin
Links that I've read:
How Do I Run ./configure with MinGW?
Getting mingw-get to install correctly - mingw/msys path missing plus more!
MinGW's configure doesn't work after reinstalling Git for Windows and GCC_TDM too (No idea how to run configure).
Any ideas how to build the library or at least find missing source files (or make through CSound, Faust, ...) ?
The Soundpipe build system is designed to be used with POSIX environments, of which there are a few to choose from on Windows.
I've been able to build Soundpipe using both MSYS2 and Windows Bash on Windows 10.
I am trying to compile Infomap (community detection algorithm) to a python module as given in http://www.mapequation.org/code.html#Input but end up getting errors as below -
\examples\python>make
cd ../.. && make python
Access denied - SRC
File not found - -NAME
Access denied - SRC
File not found - -NAME
Access denied - INTERFACES/SWIG
File not found - -NAME
make[1]: Entering directory `/d/PythonInstallables/Infomap/Third_Trial/mapequation-infomap-55e7e922c554/mapequation-infomap-55e7e922c554'
cp: missing destination file operand after `build/py/'
Try `cp --help' for more information.
make[1]: *** [py-build] Error 1
make[1]: Leaving directory `/d/PythonInstallables/Infomap/Third_Trial/mapequation-infomap-55e7e922c554/mapequation-infomap-55e7e922c554'
make: *** [../../build/py/infomap.py] Error 2
Python version 2.7.7 (64-bit) on Windows 7.
Any clues regarding what might be wrong are welcome.
Also, i prefer to use Infomap seperately instead of through igraph as igraph does not provide advanced options as listed in the given Infomap link. Please correct me if i am wrong.
Comparing your errors:
Access denied - SRC
File not found - -NAME
Access denied - SRC
File not found - -NAME
Access denied - INTERFACES/SWIG
File not found - -NAME
with the commands in the Makefile:
HEADERS := $(shell find src -name "*.h")
SOURCES := $(shell find src -name "*.cpp")
SWIG_FILES := $(shell find interfaces/swig -name "*.i”)
it seems that the problems are related to the find utility in Windows (see Find command in windows 7).
Probably you are using Windows without a properly installed Unix-like environment or tools. If that may be the case, try installing (or re-installing) MinGW or Cygwin. A simple way is to use the automated GUI installer assistant (see MinGW - Getting Started) and install the MSYS package from the MinGW installation manager. This gives you the required compiler and find tools.
Update:
Even if the MSYS find utility is installed it has to be added to the PATH environment variable to be found. And MinGW doesn't do that by default (see link). Check the directories in the PATH by opening the command prompt and type
path
This will probably give you something like
PATH=C:\Windows\system32;C:\Windows;…
The problem is that there is another find.exe located in the system32 folder, so for the Makefile to chose the correct find tool the directory containing the MSYS find utility has to be added before the system32 in the PATH.
Assuming the below location for MSYS you can do that by open a command prompt and type
set path=C:\MinGW\msys\1.0\bin;%PATH%
This will set the directory of the MSYS find utility before all other directories to look up (expanded from the PATH environmental variable).
Note:
The above solution updates the path only for that session, so each time you open a new command prompt you have to type this in order to compile Infomap.
But adding it permanently first in the system wide PATH is not recommended as the MSYS utilities will shadow default Windows utilities with the same name, which may break other programs if they don't use absolute paths.
That is why the Getting Started guide writes
We prefer that you use a script to set PATH for the processes on a per
session basis. This is the reason that we do not adjust the PATH.
You can simplify the procedure by doing this:
My Computer > Properties > Advanced System Settings > Environment Variables
Here are two lists, the top one for user variables and the one below for system variables. Here you can check and edit the system wide PATH variable. But instead, create a new user variable and with the name and value like this:
Variable name: USE_MSYS
Variable value: set path=C:\MinGW\msys\1.0\bin;%PATH%
Then when you need to use the MSYS utilities in the command prompt, just type
%USE_MSYS%
as a shortcut for the above.
MSYS also provide its own shell with the environmental variables already set up, but you have to configure it to find your files instead (see the link about fstab).
I'm writing a method for Oracle in C++. I’m using the OCI library with Eclipse as my IDE. The code compiled completely but I’m getting this runtime error:
"error while loading shared libraries: libocci.so.11.1: cannot open shared object file: No such file or directory "
I included occi and clntsh and nnz11 through properties > c/c++ general /Path and symbols > libraries
I don't know how to fix this error, please help thanks you
IDE wont take like libocci.so.11.1
you have to convert into like libocci.so
ln -s libocci.so.11.1
then it will be renamed to libocci.so
then compile the code
Your compiler finds the libraries because your project probably specifies where to look for libs (-L flag on the linker command line). But the runtime linker needs to find the libs as well.
I assume you're running it on linux. You have 2 options:
A temporary solution is to define in your environment LD_LIBRARY_PATH=full path to dir where libocci.so* is installed. I'm not very familiar with eclipse, but there's likely a setting to change the runtime environment. You could also set LD_LIBRARY_PATH and then run ecplise in that env.
$ export LD_LIBRARY_PATH=...
$ command to run eclipse
A permanent solution is to add the full path to the dir. where the libs are to the file /etc/ld.so.conf, or better: create a file /etc/ld.so.conf.d/oracle and put the path in that file, nothing else. Then, as root, run ldconfig.
wow . finally i did it , by one variable and put it into .bashrc
1- export LD_LIBRARY_PATH=/opt/oracle/instantclient "The Path of libraries" and then
2- root#user:~# vi .bashrc "Make sure you are in root"
3- LD_LIBRARY_PATH=/opt/oracle/instantclient/ "Add this two lines into file"
export LD_LIBRARY_PATH
:)