I have downloaded the boost library and want to include it in visual c++, but after copying in a piece of example code from the boost website, I get the error
"LNK1104 cannot open file 'libboost_regex-vc100-mt-gd-1_54'"
The file certainly exists. I'm guessing it was created when I ran the bootstrap command in the command prompt, which I followed from the guide https://www.youtube.com/watch?v=6trC5zVXzG0
The example file I use is as follows:
#include <boost/regex.hpp>
#include <iostream>
#include <string>
using namespace std;
int main()
{
string line;
boost::regex pat("^Subject: (Re: |Aw: )*(.*)");
while (cin)
{
getline(cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
cout << matches[2] << endl;
}
return 0;
}
I'm sorry but I know this kind of question has appeared several times on stack overflow, but I have tried most of the solutions I've seen and the error still exists.
Inside the solution explorer in visual c++ 2015, I write click on my proect and then click on properties, then under the VC++ directories tab, I've added the directory "C:\Program Files\Boost" into include directories, and the directory "C:\Program Files\Boost\stage\lib" into library directories. But the problem still exists. Similar questions on stack have asked to add the directory "C:\Program Files\Boost\stage\lib" to the Additional Include Directories under the general tab under the C/C++ tab, and to the Additional Include Directories under the General tab inside the Linker tab. But all these changes made no difference to the error. Another solution on stack said to add the directory "C:\Program Files\Boost\stage\lib" to the Additional dependencies under the input tab under the Linker tab, but when I did this the error changed to:
"LNK1104 cannot open file 'C:\Program Files\Boost\stage\lib.ob'"
I'm not sure if this is an improvement to the error or not
So after trying all these solutions which seemed to work for other people, I keep getting the same error. So does anyone know what could be the cause of the error.
You are getting a LNK error, which means it's likely that something is missing from your Linker properties. Make sure you've added both the boost folder and the boost\stage\lib folder to the Project Properties > configuration > Linker > "Additional Library Directories".
Also note that if you're using Visual Studio 2015, you should probably have generated the boost binaries using msvc-14.0, not msvc-10.0. Otherwise, your Platform Toolset property should be set to v100 (the default will be v140). You change this setting from Project Properties > configuration > General > "Platform Toolset", but you would need to have that version of visual studio installed.
If Aciel's answer haven't solve your problem(because I saw you haven't accept that answer yet), I believe it is because you compile your boost lib to 32-bit, and you use them in a 64-bit program.
If it's so, please try
bjam --toolset=msvc-14.0 --build-type=complete address-model=64
to rebuild your boost lib to 64-bit
Related
Though it perfectly compiles (CMakeFiles.txt contains proper include_directories), in editor I have "not found" for opencv2 at
#include <opencv2/opencv.hpp>
and name resolution and completion doesn't work of course, marking them "can't resolve".
What am I doing wrong?
seems include_directories absolute path doesn't work for editor at least on windows - relative path from the project folder macro made the trick...
The VS environment variable is set beforehand with vcvars32.bat, and VS is the only compiler that I use; the OS is win 7.
The error happens with cmake-gui; specifying the compiler with path results in error 'compiler failed to make simple test'; alternatively, cmake -i from command line succeeds initially with presenting an 'options' menu which then fails to allocate a 'cmakelists.txt' file (which is somewhere deeper in the cmake folder).
Where am I going wrong?
(I continued with building the solution files from VS 12, but there's other issues.)
The answer to your question from cmake mailing list
Run cmake-gui FROM the target environment, just like you run cmake...
i.e. : type "cmake-gui" in the cmd prompt that has your stuff set up
in it. Don't just launch it from a short-cut unless you're using the
"Visual Studio *" generators. Those do not need any special
environment. Many of the makefile ones do.
I have downloaded the PHP Pthreads dll file from http://windows.php.net/downloads/pecl/releases/pthreads/ and enabled it in php.ini as below:
extension=pthreadVC2.dll
extension=php_pthreads.dll
I have used below sample code:
<?php
class AsyncOperation extends Thread
{
public function __construct($arg){
$this->arg = $arg;
}
public function run(){
if($this->arg){
printf("Hello %s\n", $this->arg);
}
}
}
$thread = new AsyncOperation("World");
if($thread->start())
$thread->join();
when i executed the code i get the following error:
Fatal error: Class 'Thread' not found in C:\htdocs\threads\AsyncOperation.php
on line 2 Call Stack: 0.0008 333464 1. {main}()
C:\htdocs\threads\AsyncOperation.php:0
There are two issues here:
1) First have to look for dll files location correctly. dll files should be placed as below:
C:\PHP5\pthreadVC2.dll
C:\PHP5\ext\php_pthreads.dll
and in php.ini file only php_pthreads.dll should be enabled as
extension=php_pthreads.dll
2) Have to look for Versions of PHP and dll file.
My PHP is VC6 build and dll file used is VC9. Thats why module didn't get installed. I came to know this difference by using "php -m".
Since there is no VC6 build of dll file, I have used VC9 build of PHP and used pthreads and the program is working perfectly.
Note:The above two solutions solved my problems. But if you are still getting errors check if you have debuggers enabled xdebug or zend. Disable them and try again.
If you have installed PHP on a different folder rather than C:/PHP5, it is good to add pthreadVC2.dll to httpd.conf. Otherwise, pthreads extension module can not find it.
LoadFile "c:/not_default_php5/pthreadVC2.dll"
NOTE: If after adding LoadFile, still Apache can not find DLL, just remove the Loadfile line and copy the DLL to Apache bin folder.
c:/apache_home/bin/pthreadVC2.dll
I found a solution that worked for me:
You should first verify you've downloaded the right package for your specific system (php version, 64/32 bit system).
After that, you should include the relevant files in multiple places. It's really important to put them in every place described since otherwise it just won't work.
You should also change your php.ini file as described above (only for the php_pthreads.dll).
I've been using this with WAMP on a Windows 7 64 bit system.
In my project I have to read the numbers from the image(.jpg or .tiff). After googling a lot, I came to know about the open OCR i.e., Tesseract OCR. Am begginer for Tesseract OCR, I read all the documentation of tesseract & how to use it in Visual studio. Bascically am facing some problem in using tesseract... I followed the steps like this:
1) Downloaded & Installed tesseract-ocr-setup-3.02.02.exe from http://code.google.com/p/tesseract-ocr/downloads/detail?name=tesseract-ocr-setup-3.02.02.exe
2)Open up Microsoft Visual Studio 2008 and go to Tools -> Options
Project solutions -> VC++ Directories -> Show directories for include files
Add:
C:\Program Files\Tesseract-OCR\include
C:\Program Files\Tesseract-OCR\include\tesseract
C:\Program Files\Tesseract-OCR\include\leptonica
3) Next click show directories for -> Library Files
Add:
C:\Program Files\Tesseract-OCR\lib
4) Configure linker options for Tesseract
Right click your project in solution explorer and click properties
Configuration Properties -> Linker->Input ->Additional Dependencies
Add this in there:
libtesseract302.lib
libtesseract302d.lib
liblept168.lib
liblept168d.lib
5) Copy liblept168.dll, liblept168d.dll, libtesseract302.dll and libtesseract302.dll from C:\Program Files\Tesseract-OCR\ into your project folder
6) main.cpp source file looks like this :
#include<baseapi.h>
#include <allheaders.h>
#include <iostream>
using namespace std;
int main(void){
tesseract::TessBaseAPI api;
api.Init("", "eng", tesseract::OEM_DEFAULT);
api.SetPageSegMode(static_cast<tesseract::PageSegMode>(7));
api.SetOutputName("out");
cout<<"File name:";
char image[256];
cin>>image;
PIX *pixs = pixRead(image);
STRING text_out;
api.ProcessPages(image, NULL, 0, &text_out);
cout<<text_out.string();
}
The problem is am unable to compile this code.. Am getting linker error i.e., LINK : fatal error LNK1181: cannot open input file 'libtesseract302.lib'.
As I downloaded Tesseract OCR. In Tesseract-OCR\lib am not finding libtesseract302.dll and libtesseract302.dll files.. Am able to see only liblept168.dll, liblept168d.dll files.
I tried to searching for libtesseract302.lib & libtesseract302.dll but am not getting anything.
Am totally struck up at this point.
If anyone has used Tesseract OCR, please suggest me on this.
Thank you all..
Today is officially my first day with C++ :P
I've downloaded Visual C++ 2005 Express Edition and Microsoft Platform SDK for Windows Server 2003 SP1, because I want to get my hands on the open source Enso Project.
So, after installing scons I went to the console and tried to compile it using scons, but I got this error:
C:\oreyes\apps\enso\enso-read-only\src\platform\win32\Include\WinSdk.h(64) : fatal error C1083: Cannot open include file: 'Windows.h': No such file or directory
scons: *** [src\platform\win32\InputManager\AsyncEventProcessorRegistry.obj] Error 2
scons: building terminated because of errors.
After checking these links:
VS ans PSDK
Include tiffi.h
Wndows.h
I've managed to configure my installation like this:
And even run this script
And I managed to compile the file below in the IDE.
// Test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
But I still get that exception in the console. Does anyone have scons experience?
EDIT
Actually (and I forgot to tell you this) I started the command prompt with the link "Visual Studio 2005 Command Prompt".
I assume this will include the paths in environment variables. Well after printing them I find that it didn't:
echo %INCLUDE%
echo %LIB%
echo %PATH%
And they were not present, so I created this .bat file:
set PATH=%PATH%;"C:\Program Files\Microsoft Platform SDK\Bin"
set INCLUDE=%INCLUDE%;"C:\ Program Files\Microsoft Platform SDK\Include"
set LIB=%LIB%;"C:\ Program Files\Microsoft Platform SDK\Lib"
Still, scons seeems not to take the vars... :(
Using the above recommendations will not work with scons: scons does not import the user environment (PATH and other variables). The fundamental problem is that scons does not handle recent versions of SDKs/VS .
I am an occasional contributor to scons, and am working on this feature ATM. Hopefully, it will be included soon in scons, but the feature is much harder to implement reliably than I first expected, partly because every sdk/compiler combination is different (and sometimes even MS does not get it right, some of their .bat files are broken), so I can't give you a date. I hope it will be included in 1.2 (to be released in approximatively one month).
You need to set the include file path (and possibly other things). At the command line this is typically done using a batch file that Visual Studio installs called vsvars32.bat (or vcvars32.bat for compatibility with VC6).
I'm not familiar with scons so I don't know the best way to get these settings configured for that tool, but for standard makefiles there's usually a line in the makefile which sets a macro variable with the include directory path and that macro is used as part of a command line parameter in the command that invokes the compiler.
Another possibility might be to have the scons process invoke vsvars32.bat or run the scons script from a command line that has been configured with the batch file.
In short you need to get the things that vsvars32.bat configures into the scons configuration somehow.
There will be a batch file similar to this one (for MSVC 2005) that sets up the environment variables:
c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat
Step 1: Find a similar file in the Express installation folders
Step 2: Create a shortcut on the desktop with these target details and a suitably modified path:
cmd.exe /K "c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"
Step 3: Open the DOS prompt via this shortcut
The command line build should now work from within this console window.
You show us how you configured Visual Studio for compilations within Visual Studio but you didn't show us what command line environment you tried. Sorry I haven't tried Express versions so I don't know if they create additional Start menu shortcuts like Pro and above do. If you open a suitable command prompt with its environment variables already set then you can compile on the command line. Otherwise you have to set variables yourself or execute a batch script to set them, each time you open a command prompt.
It'll be nice when scons does this automatically. For now, I use this (run from an SDK command prompt, not sure if there is a difference if run after vsvars32.bat):
import os
env = Environment(ENV={'PATH': os.environ['PATH']})
env['ENV']['TMP'] = os.environ['TMP']
env.AppendUnique(CPPPATH=os.environ['INCLUDE'].split(';'))
env.AppendUnique(LIBPATH=os.environ['LIB'].split(';'))
This works for me while compiling wxwidgets with Visual C++ 2005 Express using the command line prompt:
REM Fix Error error C1083 'windows.h'
(Use /useenv option when compiling.)
set PDSKWIN=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2
(Change to the right one.)
set INCLUDE=%PDSKWIN%\Include;%INCLUDE%
set LIB=%PDSKWIN%\Lib;%LIB%
Then I use this line when compiling. I believe just add /useenv to your lines and everything should work fine:
vcbuild /useenv /nohtmllog /nologo name.proj (or any file to compile)