I want to use C++ OpenCascade (OCE) libraries within a C++ program with vs2017 inside a linux subsytem (ubuntu) from windows 10.
I compiled OCE into the linux subsystem; I also have the OCE compiled binaries in windows.
When I try to include a header from OCE in my code (#include <Adaptor2d_Curve2d.hxx>), I get this error :
error : Adaptor2d_Curve2d.hxx: No such file or directory
error : #include <Adaptor2d_Curve2d.hxx>
error : ^~~~~~~~~~~~~~~~~~~~~~~
error : compilation terminated.
I added OCE include path in my vs project in additional include directories from using $(ProjectDir) or $(RemoteRootDir) path. I checked, the paths are corrects.
I have created a linux console application.
My code :
// from oce
#include <Adaptor2d_Curve2d.hxx>
int main()
{
printf("hello from CAO3DConverterTestApp!\n");
return 0;
}
I've added theses lines into Additional Include Directories in my project settings
$(ProjectDir)..\oce-0.18.3\include\oce
$(RemoteRootDir)..\oce\build\inc
So what is the procedure to add external libs and headers in C++ code using vs2017 in linux subsystem from windows 10 ?
Here is a minimal projet with Boost dependancies instead of OCE
build a c++ linux console app with vs2017, using ubuntu linux subsytem.
include boost headers path in Additional Include Directories from project properties
add #include <any.hpp> (header from boost) into main.cpp file
The -I statements are corrects -I "C:\<myPath>\dependencies\boost_1_68_0\boost\", but I still have the error
error : any.hpp: No such file or directory
error : #include <any.hpp>
error : ^~~~~~~~~
error : compilation terminated.
What else should I do ?
refs : https://blogs.msdn.microsoft.com/vcblog/2017/02/08/targeting-windows-subsystem-for-linux-from-visual-studio/
Can't really debug your project without a minimal example, but here is something that can help you figure out what is going on:
In VS2017 right click your project, select properties. Under C/C++ choose command line.
Here you can see the command line the IDE is using to compile your source files. Check all /I statements and make sure one of them points to where Adaptor2d_Curve2d.hxx is located.
Related
I try to compile a cpp file with this header:
#include <stdlib.h>
#include <gtk/gtk.h>
I work with MSYS2, so both the compiler and the gtk library are installed through it. The cpp compiler path is:
D:\msys\usr\bin\cpp.exe
and here is the VS code include path additions, which I supplied to the IntelliSense Configurations page under "include path":
D:\msys\mingw64\include\gtk-2.0\**
D:\msys\mingw64\include\**
D:\msys\mingw64\lib\**
D:\msys\usr\include\**
and I have gtk etc. in the include folder. I actually installed three different versions of gtk, 2-4.
Before I added them to the include path, I got an error like "cannot open source file", and after adding them I get the
fatal error: gtk/gtk.h: No such file or directory
error. gtk/gtk.h is located just inside gtk-2.0. What am I doing wrong?
Thanks a lot.
i need to include libcurl in my unreal engine project, i need to use it in game, how i can do it? i have tried standard tutorial for include curl in visual studio, but not work.
the compiler return error on other portion of code if i include curl with following code
#include <curl\curl.h>
I have tried also to change separator to / but nothing, i have read about thirdbart library but how i can add curl?
other questione, look in Visual Studio project, curl.h is included in extetrnal reference for Engine project, but not in Game project.. how i can include?
EDIT
i have included the directory
C:\Lib\curl\builds\libcurl-vc-x64-release-static-ipv6-sspi-winssl\include\
lib direcotry
C:\curl\builds\libcurl-vc-x86-release-static-ipv6-sspi-winssl\lib\
when include curl show this error when i compile:
If i remove #include curl\curl.h from code it compile fine.
I have solved!, You must add the path of library in VC++ tab in , includes directory and lib directory, after you must add this line in you build.cs
PublicAdditionalLibraries.Add("path to lib file");
PublicIncludePaths.Add("path to includes directory");
have nice day!
I'm setting up a c++ visual studio project to use ImageMagick's api, Magick++, for image processing. However, when I try to include <Magick++.h> in the only cpp file in the whole solution/project, I encounter this error:
fatal error C1083: Cannot open include file: 'Magick++.h': No such file or directory
I tried right-clicking Magick++.h in my code and pressing open document <Magick++.h>. This lead to an error message, which says the file is not found in current source file's directory or in build system paths. However, in the error message, the Build System Path clearly says the path to the include directory.
I have:
added the include directory of ImageMagick-7.0.9-Q16 in the project's properties->C/C++
->Additional Include Directories.
added the lib directory of ImageMagick-7.0.9-Q16 in the project's properties->Linker->Additional Library Directories
added CORE_RL_Magick++_.lib, CORE_RL_MagickCore_.lib, and CORE_RL_MagickWand_.lib in the project's properties->Linker->Additional Dependencies
Made sure everything is x64
Set the configuration to release
I somehow made Magick+++_demo project, the one that comes with magick++, work after tinkering with the settings. However, I cannot make other projects/solutions work. I have checked the settings of the demo project and tried to replicate it in my project where appropriate, but I cannot make my own project work.
this is the only code:
#include "pch.h"
#include <Magick++.h>
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
I have been googling and trying to make this work for the last 6 hours. Any help is hugely appreciated.
I had Microsoft Visual Studio Community 2013 (Version 12.0.31101.00 Update 4) and Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017) on my PC with Windows 10 Pro.
In order to try examples with Boost.Python I downloaded boost 1.64.0 and build libraries by b2 with options --with-python --toolset=msvc --build-type=complete. As a result I have the following files:
boost_python3-vc120-mt-1_64.dll
boost_python3-vc120-mt-1_64.lib
boost_python3-vc120-mt-gd-1_64.dll
boost_python3-vc120-mt-gd-1_64.lib
libboost_python3-vc120-mt-1_64.lib
libboost_python3-vc120-mt-gd-1_64.lib
libboost_python3-vc120-mt-s-1_64.lib
libboost_python3-vc120-mt-sgd-1_64.lib
libboost_python3-vc120-s-1_64.lib
libboost_python3-vc120-sgd-1_64.lib
Then I created project (type: Win32 / DLL) in Visual Studio with the following code taken here:
char const* greet()
{
return "hello, world";
}
#include <boost/python.hpp>
BOOST_PYTHON_MODULE(hello)
{
using namespace boost::python;
def("greet", greet);
}
In project properties for C/C++ settings I added "Additional Include Directories" to locations of Boost and Python (ends with \Python36\include).
During the first attempt to build the project an error appears:
Error 1 error LNK1104: cannot open file 'python36.lib'
So in project properties for Linker settings "Additional Library Directories" I added corresponding location (ends with \Python\Python36\libs). After that I could move on ... to the next error:
Error 1 error LNK1104: cannot open file 'boost_python-vc120-mt-gd-1_64.lib'
It is noteworthy that the difference in filenames I had and VS2013 looking for is just digit 3 after word python.
Similar questions at stackoverflow and in google groups are discussed but without valuable tips. The only useful information is that library file names *boost_python-* corresponds to Python 2 and *boost_python3-* to Python 3.
I noticed that changing the build type (Solution Configuration) from Debug to Release leads to change the error message in part of library file name (there is no -gd- now):
Error 1 error LNK1104: cannot open file 'boost_python-vc120-mt-1_64.lib'
I suppose, VS2013 knows boost library file name convention, but probably does not know the difference about Python 2 and Python 3.
So, I have 3 questions:
Is it possible to influence the logic used by VS to look for Boost.Python library? (Of course lib-files renaming is also an option, but I do not like this for some reason)
Do the linker options allow specifying lib-file directly? (i.e. I can write whole path to the boost_python3-vc120-mt-1_64.lib including file name, not just folder name in section "Additional Library Directories")
What option in the project properties should make VS2013 to use different LIB or DLL files, e.g. libboost_python3-vc120-mt-1_64.lib or boost_python3-vc120-mt-1_64.dll instead of boost_python-vc120-mt-1_64.lib?
With the community help I have found answers to couple of the questions.
Is it possible to influence the logic used by VS to look for Boost.Python library?
Name of library depends on value defined as macro BOOST_LIB_NAME in file boost/python/detail/config.hpp.
I have tried to change line (108 in boost 1.64.0)
#define BOOST_LIB_NAME boost_python
to
#define BOOST_LIB_NAME boost_python3
And desirable library file changed from boost_python-vc120-mt-1_64.lib to boost_python3-vc120-mt-1_64.lib.
It should be noted, that instead of changing values in config.hpp file auto_link.hpp can be created and used with redefinition of BOOST_LIB_NAME.
What option in the project properties should make VS2013 to use different LIB or DLL files, e.g. libboost_python3-vc120-mt-1_64.lib or boost_python3-vc120-mt-1_64.dll instead of boost_python-vc120-mt-1_64.lib?
That is also regulated by defines.
In particular, adding to the beginning of my code (before #include <boost/python.hpp>) the line
#define BOOST_PYTHON_STATIC_LIB
forces MSVS to search file libboost_python3-vc120-mt-1_64.lib (or libboost_python-vc120-mt-1_64.lib), i.e. static lib.
And vice versa line
#define BOOST_PYTHON_DYNAMIC_LIB
or
#define BOOST_ALL_DYN_LINK
can be used to import code from a dll.
I am using Dlib for face landmark detection for my academic project.
When I am running Dlib 19.2 face_landmark_detection_ex.cpp file in Visual Studio 2015 express, I wasn't able to get the results.
The steps followed
Created new project.
Added existing face_landmark_detection_ex.cpp and source.cpp file from dlib\all folder and added same files to project folder
In VC++ directories added this path D:\dlib-19.2\dlib-19.2 as Include Directories.
Downloaded shape_predictor_68_face_landmarks.dat file.
In the command line argument 'shape_predictor_68_face_landmarks.dat download.jpg' here shape_predictor_68_face_landmarks.dat i have added in project folder and download.jpg is my image file .
Added dlib/external folder to project.
Added #define DLIB_JPEG_SUPPORT
Questions: So many errors in file and not able to understand what is happening.
Your project is not inheriting the include directorys. I think you set "D:\dlib-19.2\dlib-19.2" as the only include dir. Errors like "cannot open source file string" are not related to your code, they are related to your project settings.
Also note:
Again, note that you should not add the dlib folder itself to your compiler's include path. Doing so will cause the build to fail because of name collisions (e.g. dlib/string.h with string.h from the standard library). Instead you should add the folder that contains the dlib folder to your include search path and then use include statements of the form #include . This will ensure that everything builds correctly.
Correct your includes. If E:\dlib-1.92.2\dlib is in your include path, then you should use: #include <image_processing/frontal_face_detector.h>
To fix the cin/cout errors, use std::cin, std::cout and std::endl