Windows C++ How to install GLFW library? - c++

I am coding window part of my game. Code gives error. I think the reason of the error is the lack of GLFW library. I am using Notepad++ for editing and MinGW for compiling. How can I install a library to my folder?
Error:
NPP_SAVE: C:\Users\User\Desktop\game\src\main.cpp
CD: C:\Users\User\Desktop\game\src
Current directory: C:\Users\User\Desktop\game\src
g++ "main.cpp" -o main -march=native -O3
Process started (PID=1568) >>>
In file included from main.cpp:4:
Display.h:7:10: fatal error: GLFW/glfw3.h: No such file or directory
#include <GLFW/glfw3.h>
^~~~~~~~~~~~~~
compilation terminated.
<<< Process finished (PID=1568). (Exit code 1)
NPP_RUN: main
; executing: NPP_RUN main
- the specified file was not found
================ READY ================

You don't install a library, you just need to tell the compiler where to find the headers and libraries you require. How you do this depends on your build environment.
If you use only mingw g++ you need the following options:
-I (that's an uppercase i!)(specify path to include files, in your case the path to glfw/include directory)
-L (path to libraries, in your case to the folder that contains glfw3.lib)
-l (that's a lower case L!)(a list of libraries to use, in your case glfw3, without the extension)

Related

cmake CheckIncludeFiles fatal error sys/tree.h No such file or directory while the file exists

Clearwater sprout project contains a lot modules. One of them is libevhtp, at Github libevhtp.
INCLUDE (CheckIncludeFiles)
CHECK_INCLUDE_FILES(sys/tree.h HAVE_SYS_TREE)
if (NOT HAVE_SYS_TREE)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/compat/sys/tree.h.in ${CMAKE_CURRENT_BINARY_DIR}/compat/sys/tree.h)
endif(NOT HAVE_SYS_TREE)
In wsl Ubuntu, system does not have sys/tree.h, so it uses build/libevhtp/compat/sys/tree.h to compile. And it compiles successfully.
In CentOS, system does not have sys/tree.h either, but instead of using build/libevhtp/compat/sys/tree.h, cmake gives an error:
Building C object CMakeFiles/cmTryCompileExec667563402.dir/CheckIncludeFiles.c.o
/bin/cc -o CMakeFiles/cmTryCompileExec667563402.dir/CheckIncludeFiles.c.o -c /home/tiina/clearwater/sprout/build/libevhtp/CMakeFiles/CMakeTmp/CheckIncludeFiles.c
/home/tiina/clearwater/sprout/build/libevhtp/CMakeFiles/CMakeTmp/CheckIncludeFiles.c:2:22: fatal error: sys/tree.h: No such file or directory
#include <sys/tree.h>
I checked CMakeCache.txt in both WSL and CentOS, they are the same:
HAVE_SYS_TREE:INTERNAL=

How to compile tesseract baseapi.h with MinGW on window?

So I want to use tesseract api on my project.
And the problem is I don't know how to compile this baseapi.h with MinGW on window.
I'm using this
g++ -I/[...]/project/tesseract-master/include/ -I/[...]/project/leptonica/src/ t.cpp -o t
and got
In file included from t.cpp:2:
/[...]/project/tesseract-master/include/tesseract/baseapi.h:33:10: fatal error: tesseract/version.h: No such file or directory
#include <tesseract/version.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
I think the problem is about version.h file, It's actually a version.h.in file
leptonica also have same problem with .h.in file
I don't know if MinGW can compile this type of file, so if there's a way or it can't pls tell me thanks.
g++.exe (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0
Tesseract from main branch https://github.com/tesseract-ocr/tesseract
Leptonica from 1.80.0 release
https://github.com/DanBloomberg/leptonica
It seems that you did not install tesseract - otherwise version.h (actually generated during tesseract build/compilation) would be present.

How to run a .cpp file with Gecode Framework on Linux?

I use Ubuntu 18.04 and try to compile the example 'money.cpp' file that Gecode brings. I downloaded (gecode-release-5.1.0.tar.gz) and extract it. Then to install Gecode I do the following steps:
(1) ./configure
(2) make
I get satisfactory installation.
Then I try to compile money.cpp, like this:
$g++ money.cpp
and I get the following error:
fatal error: gecode / driver.hh: No such file or directory
  #include
           ^ ~~~~~~~~~~~~~~~~~
I know the problem is that it does not recognize the libraries, but how can I make my .cpp or compile phase recognize them?
regards!
Alberto
You need to call g++ with the -I flag so that g++ knows where to look for the include files:
g++ -I<dir> money.cpp
<dir> is the source code directory for the files (the one with structure as seen on GitHub):
https://github.com/Gecode/gecode
See Compiling with g++:
https://courses.cs.washington.edu/courses/cse373/99au/unix/g++.html

Error message while compiling a program

I’m a newbie to C++ and Linux. There is this code I’m playing with that requires me to install the HElib (Homomorphic encryption library and other libraries - GMP, NTL) which I did. I want to compile the code (main.cpp) that has a header file (FHE.h) in HElib. My problem is how can I link FHE.h (in HElib folder) and main.cpp (in another folder) together so that I can compile them. I have tried some commands
g++ -I/Home/HElib/src/FHE.h main.cpp -o main
Error message
main.cpp:1:17: fatal error: FHE.h: No such file or directory
compilation terminated.
Another command line
g++ -I/Home/HElib/Src/FHE.h -I/Home/SimpleFHESum-master/SimpleFHESum-master/main.cpp -o main]
Error Message
g++: fatal error: no input files
compilation terminated.
What's wrong and how can I fix this?
The -I flag adds the following directory to the include path of the compiler. This enables you to write e.g. #include "FHE.h" even though that file is not located in the same folder as the source file you're trying to compile.
Have you tried just removing the 'FHE.h' part from your -I directive?
g++ -I/Home/HElib/src ...

"fatal error: boost/regex.hpp: No such file or directory" when trying to compile C++ program using a makefile

I am trying to compile a piece of open source software called "SPECIES
Identification of Taxonomic Mentions in Text". I am on MacOS.
I downloaded the source code (which can be found here), moved into the directory and used the command make to compile. This is the error returned:
g++ -fpic -pthread -Wall -O3 -o organisms organisms.cxx -lm -lboost_regex
In file included from batch_tagger.h:5:0,
from organisms.cxx:3:
tagger.h:7:27: fatal error: boost/regex.hpp: No such file or directory
compilation terminated.
make: *** [organisms] Error 1
I installed the C++ boost library using brew install boostand tried the above steps again (it did not work).
I tried dropping the boost directory into the directory containing the source code (it did not work).
Any suggestions/help?
You need to tell the compiler where to find boost headers.
You need to use the include path option to specify where the boost headers can be find, use -I/path/to/boost/include.
Then include the file using #include <boost/regex.hpp> from your code.