CMake Error at 3rdparty/libtiff/CMakeLists.txt:27 (ocv_include_directories): Unknown CMake command "ocv_include_directories" - c

Right, so I'm trying to build a project in VS2012 and I've been chasing down various errors for the past 2 days...I'm coming in on a lot of legacy code, and it deals with OpenCV2.1
So after chasing down all the 3rd party files I needed, I now get the following error:
error C1021: invalid preprocessor command 'cmakedefine' c:\opencv2.1\3rdparty\libtiff\tif_config.h
Line:
/* Define to 1 if you have the <assert.h> header file. */
#cmakedefine HAVE_ASSERT_H
Which the only help I found here:
cannot compile allegro using visual c++
suggesting that I need to rebuild OpenCV with cmake. At which point I get the error:
CMake Error at 3rdparty/libtiff/CMakeLists.txt:27 (ocv_include_directories): Unknown CMake command "ocv_include_directories".
In the visual editor. So I traced that to here.
So I run it in command line as:
cmake C:/OpenCV2.1 -DBUILD_SAMPLES=ON
Which spits out more errors:
CMake Error at 3rdparty/libtiff/CMakeLists.txt:5 (project):
project PROJECT called with incorrect number of arguments
CMake Error at 3rdparty/libtiff/CMakeLists.txt:27 (ocv_include_directories):
Unknown CMake command "ocv_include_directories".
I can't find any documentation for ocv_include_directories. I've tried following multiple OpenCV cmake tutorials, but haven't had any success.

It turns out the problem was actually that I had visual studio 2012, and the codebase I was working in was visual studio 2008 built. There was no possibility to ever track down all of these errors. Solution was to uninstall 2012 and install 2008.

Related

How to compile using EiffelStudio? VD43 Precompiled file is missing or unreadable (...)/driver.exe - External C compilation failed

After installing EiffelStudio I can't compile and run any project because I always get VD43 warning and C Compiler Error.
2 VD43 Precompiled file is missing or unreadable. File 'c:\users\username\documents\eiffel user files\19.05\precomp\spec\win64\EIFGENs\base-scoop-safe\W_code\msc_vc140\driver.exe'.
1 C Compiler Error Please review the External Compilation output of the Outputs Tool.
Error code: C Compiler Error
Error: External C/C++ compilation failed.
What to do: Check the external C/C++ compilation for details.
Please review the External Compilation output of the Outputs Tool.
I found this page: https://www.eiffel.org/doc/version/trunk/faq/FAQ. The key ISE_C_COMPILER must be additionally defined in order for EiffelStudio to work at all. But how does one "Tell EiffelStudio to use Visual Studio 2017-compatible libraries"? I tried setting it as an environment variable, and changing the compile_library.bat and esvars.bat, so that in every place it's set ISE_C_COMPILER=msc_vc140. I also added variable ISE_C_COMPILER - msc_vc140 on the EiffelStudio GUI, under Project->Project Settings->Target:project->Advanced->Variables
I deleted all the projects and the precomp folder. I ran espawn -l just to verify that I have the good c++ compiler:
Available C/C++ compilers:
VC160: Microsoft Visual Studio 2019 VC++ (19.0)
VC150: Microsoft Visual Studio 2017 VC++ (15.0)
To me it seems that I installed everything and I set every variable but it still gives me the same warning and error.

How to solve libatomic issue in windows?

I am developing executables from source code of llvm. So I downloaded the llvm source code from github.
I am trying everything from command line on Windows OS
I am following the link for libtooling in clang
http://clang.llvm.org/docs/LibASTMatchersTutorial.html
I tried with 2 options
Option First: I ran the below command
cmake -G Ninja "C:\Users\amith.ks\Desktop\Clang-llvm\llvm-project\llvm" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DLLVM_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
Everything Worked..
Second option:
I wan to set cmake_c_compiler and cmake_cxx_compiler from command line.
I dont want to use cmake-gui so I run the below command
cmake -G Ninja "C:\Users\amith.ks\Desktop\Clang-llvm\llvm-project\llvm" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" -DLLVM_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
From out of no where error was thrown
CMake Error at cmake/modules/CheckAtomic.cmake:53 (message):
Host compiler appears to require libatomic, but cannot find it.
Call Stack (most recent call first):
cmake/config-ix.cmake:343 (include)
CMakeLists.txt:617 (include)
When I saw the cmake error log It was saying this
LINK : fatal error LNK1104: cannot open file 'atomic.lib'
clang: error: linker command failed with exit code 1104 (use -v to see invocation)
ninja: build stopped: subcommand failed.
I searched my whole pc atomic.lib no where to be found.
How to solve this issue on windows?
Please help me with answers.
I know why it fails. It's a bug in the LLVM's cmake files. In order to check if atomic.lib is required CheckAtomic.cmake tries compiling and linking a piece of code with atomic.lib. When it fails (because atomic.lib is not required and thus is not present) it falsely concludes that atomic.lib is needed. LLVM's cmake files is a hot mess with rarely fixed bugs. There are bugs staying there for years. I guess this is because nobody understands anymore how LLVM build system works.
Long story short, I couldn't find why CheckAtomic.cmake inserts atomic.lib while checking that it is not required. As a workaround I just unconditionally set HAVE_CXX_ATOMICS64_WITHOUT_LIB and HAVE_CXX_ATOMICS_WITHOUT_LIB to True in CheckAtomic.cmake:
set(HAVE_CXX_ATOMICS64_WITHOUT_LIB True)
set(HAVE_CXX_ATOMICS_WITHOUT_LIB True)
Use clang-cl (or MSVC cl), they dont require lib atomic.
I'm trying to use Clang 11 (with MSVC ABI) to compile Clang 11. However, MSVC's headers won't compile in C++11 mode, which CheckAtomic.cmake uses:
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11")
results in:
C:\Users\nyanpasu\code\llvm-project>clang -Werror=unguarded-availability-new -std=c++11 uwu.cpp
In file included from uwu.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\atomic:19:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xatomic.h:13:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\type_traits:11:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\xstddef:283:22: error: 'auto' return
without trailing return type; deduced return types are a C++14 extension
_NODISCARD constexpr auto _Unfancy(_Ptrty _Ptr) noexcept { // converts from a fancy pointer to a plain pointer
^
1 error generated.
I don't know if this is a MSVC bug where it ships an header incompatible with C++11, or a Clang bug where it's using MSVC headers instead of its own.
In any case, changing c++11 to c++14 fixes this error.
As lulle mentioned, you need to use the right tools to compile. If you have installed Visual Studio, use the Developer Command prompt for Visual Studio instead of a regular cmd and you'll have the environment variables you need. It is located in your Visual Studio installation directory, under the Tools subdirectory.
For example:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat
I encountered the same error in macOS. Adding the CPP Libraries to the path solved it for me. You can try executing the following commands.
export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
export CPLUS_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1

How to use VC++ compiler in command line(Windows)?

I tried to use VC++ commandline, instead of MinGW compiler for windows system programming. I wrote a simple hello world program and tried to compile it, then i got this error message.
test2.c(1): fatal error C1083:'stdio.h': No such file or directory
I also added "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\Hostx86\x86" directory (where c1.dll lives) to the System Envionment Variable(PATH).
How can I fix this issue? Other tutorials don't give much information about VC++. (A lot of MinGW compiler tutorial out there btw)
You should use visual studio command line if you want to compile or run program with the help of vc++ compiler.
Else all information related to setting environment variables ETC. resides in this MSDN document.

Visual Studio Community 2017 cl linker won't link GTK3 libraries?

I am writing code in C using GTK as GUI toolbox. I installed GTK3 via MSYS2 and managed to compile and build using GCC (TDM-Dragon) alright.
However, lately I am trying to compile and link using cl included in Visual Studio Community 2017 (heard it is faster and more stable). With this, I am having a hard time building an application. I am loosely following this tutorial:
http://www.tarnyko.net/en/?q=node/22
I created a BAT file and invoke it from the VS 2017 command prompt:
set GINC_PATH="C:\msys64\mingw64\include"
set GLIB_PATH="C:\msys64\mingw64\lib"
cl gtk3test.c -I"%GINC_PATH%\gtk-3.0" -I"%GINC_PATH%\glib-2.0" -I"%GLIB_PATH%\glib-2.0\include" -I"%GINC_PATH%\pango-1.0" -I"%GINC_PATH%\cairo" -I"%GINC_PATH%\gdk-pixbuf-2.0" -I"%GINC_PATH%\atk-1.0" -Dinline= /link /LIBPATH:%GLIB_PATH% gtk-3.lib gdk-3.lib gobject-2.0.lib glib-2.0.lib
This compiles alright, gives me gtk3test.obj. However, the linker returns the following error:
LINK : fatal error LNK1181: cannot open input file 'gtk-3.lib'
What am I doing wrong here? How would it be possible to use cl for linking GTK3 applications?
Thank you all in advance!
Xuttuh
Please check if you have gtk-3.lib in your folder path [%GINC_PATH%]. Even I have this issue using GTK+3.0, the package configuration is not giving the proper library reference.
The gtk library is something like gtk-win32-3.0.lib available inside lib folder %GINC_PATH%\lib in your case.
I still have issues in linking GTK libraries in my visual studio application even after providing the needed library references in Linker.

GTK Linker Issue Visual Studio C Project

it is the third day that I am trying to set up the visual studio 2013 with the GTK libraries. I need to use VS: I've used GCC (both command line and with code blocks) in the past (both on windows and slackware linux too..), but now I have a lot of projects in VS and I want to start making some GUI for them. After seeing that the so called "all-in-one-bundle" is not more available/maintained in the GTK website, I followed a bunch of tutorials (including GTK+ 3.0 setup in Visual Studio 2013, How to configure gtk on Visual studio 2010, How do you install GTK+ 3.0 on Windows?) and I started to install MSYS2 according to this one: https://blogs.gnome.org/nacho/2014/08/01/how-to-build-your-gtk-application-on-windows/.
Maybe the problem is here: I followed this step properly pacman -S mingw-w64-x86_64-toolchain, but I skipped the creation of PKGBUILD file and successive installation due to the fact that I did not understand the procedure. Furthermore the mingw toolchaing seemed to be already installed.
Sorry for the big introduction, I wanted to be specific.
The problem is at the linking-stage of Visual Studio C Project building. I had also some problem at compilation involving the different inline interpretation of VS (added #define inline __inline // Necessary to make the GTK library Visual Studio compatible definition before calling the GTK header). The linking stage issue consist in the fact that, using pkg-config --libs gtk+-3.0 --msvc-syntax command, I receive a list of files (/libpath:C:/msys64/mingw64/lib gtk-3.lib gdk-3.lib gdi32.lib imm32.lib shell32.lib ole32.lib -Wl,-luuid winmm.lib dwmapi.lib z.lib pangowin32-1.0.lib pangocairo-1.0.lib pango-1.0.lib atk-1.0.lib cairo-gobject.lib cairo.lib gdk_pixbuf-2.0.lib gio-2.0.lib gobject-2.0.lib glib-2.0.lib intl.lib) that does not exists in the msys2 directory. As a consequence I receive this error from the linker: error LNK1104: cannot open file 'gtk-3.lib'.
Someone has the same problem (see Error 3 error LNK1104: cannot open file 'gtk-3.lib'), but the solution is to use the all-in-one-bundle.
What shall I do? Have I followed the correct procedure or am I missing something? I've also tried to link to VS the *.a files located in the lib directory of mingw63 (e.g. libgtk-3.dll.a), but the linker error remains.
Best Regards and thank you for the attention
Davide

Resources