setting up GLEW windows? - visual-studio-2010

I have visual studio 2010 and I want to set up glew.h on it.
i do this step but still I have linker error:
1.download glew pack
2.copy .h files to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include
3.copy .lib files to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib
4.copy glew32.dll to C:\Windows\SysWOW64
5.and finally go to myproject properties then go to linker->input add glew32.lib,
glu32.lib, and opengl32.lib to Additional Dependencies
but I still have this error:
error LNK2001: unresolved external symbol __imp____glewBlendEquation

I've been confronted to the same issue today, so even if I'm one month late for the answer, just add GLEW_STATIC to your preprocessor's definitions.

That's a common problem. Just download the source, recompile it and it will work.

Related

Linking with Apache Portable Runtime on MS Windows

I'm trying to build a Python extension which links to APR. And this time it's on MS Windows... (It works on Linux).
Here's where the build fails, the command, and the output formatted for readability:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe
/nologo
/INCREMENTAL:NO
/LTCG
/DLL
/MANIFEST:EMBED,ID=2
/MANIFESTUAC:NO
/LIBPATH:c:\dev\protopy\lib/apr
/LIBPATH:c:\bin\python\Libs
/LIBPATH:c:\dev\protopy\.venv\libs
/LIBPATH:c:\dev\protopy\.venv\PCbuild\amd64
"/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64"
"/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64"
"/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64"
apr-1.lib
/EXPORT:PyInit_wrapped build\temp.win-amd64-3.6\Release\protopy/lib/descriptors.obj
build\temp.win-amd64-3.6\Release\protopy/lib/binparser.obj
build\temp.win-amd64-3.6\Release\protopy/lib/defparser.obj
build\temp.win-amd64-3.6\Release\protopy/lib/protopy.lex.obj
build\temp.win-amd64-3.6\Release\protopy/lib/protopy.tab.obj
build\temp.win-amd64-3.6\Release\protopy/lib/pyhelpers.obj
build\temp.win-amd64-3.6\Release\protopy/lib/list.obj
build\temp.win-amd64-3.6\Release\protopy/wrapper.obj
/OUT:build\lib.win-amd64-3.6\protopy\wrapped.cp36-win_amd64.pyd
/IMPLIB:build\temp.win-amd64-3.6\Release\protopy/lib\wrapped.cp36-win_amd64.lib
wrapper.obj : warning LNK4197: export 'PyInit_wrapped' specified multiple times; using first specification
Creating library build\temp.win-amd64-3.6\Release\protopy/lib\wrapped.cp36-win_amd64.lib \
and object build\temp.win-amd64-3.6\Release\protopy/lib\wrapped.cp36-win_amd64.exp
descriptors.obj : error LNK2001: unresolved external symbol \
__imp_apr_hash_set
(it actually misses all symbols I've used, not just this one).
I've built the apr-1.lib by running nmake -f Makefile.win in APR's top-level directory before, and this is how I produced libapr-1.lib. Then I renamed to apr-1.lib it and put it in c:\dev\protopy\lib/apr, so the linker is actually able to find it, but it cannot find the required symbols...
Question 1
How can I see what symbols are in the library? (Maybe I compiled something wrong?)
OK, I found dumpbin.exe, but now I see that the symbol in the apr-1.lib is called __imp__apr_hash_set (notice the second double underscore), but the linker looks for __imp_apr_hash_set (single underscore). What gives? They were compiled with the same compiler / linker...
Question 2
Is there anything specific to building Python extensions on MS Windows that makes it work in this way? (I only tried this once in my life, and couldn't get it to work, but for different reasons).
According to APR project document
choose either aprutil or libaprutil (for static or dynamic libraries)
means apr-1.lib-->static and libapr-1.lib -->dynamic and
To target the static .lib versions of the library, the consuming compiliation must define the macros APR_DECLARE_STATIC and APU_DECLARE_STATIC. This prevents the apr and apr-util symbols from being tagged as __declspec(dllimport), eliminating compiliation warnings and speeding up execution.

Clang C2 on Visual studio 15.5 bool_constant<__is_trivially_destructible(_Ty)> error : '_Ty' does not refer to a value

I am trying to re-compile a hello world using Clang_C2 compiler on Visual studio 15.5 (latest).
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\include\type_traits(899,2): error : expected class name
1> { // determine whether _Ty has a trivial destructor
In file included from ..\hello_boost_exception\hello_boost_exception.cpp:11:
1>In file included from I:\modular-boost\boost/config.hpp:48:
1>In file included from I:\modular-boost\boost/config/stdlib/dinkumware.hpp:98:
1>In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\include\typeinfo:22:
1>In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\include\exception:7:
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\include\type_traits(898,47):
This looks as though I have some missing or incorrect library but I can't see what.
I have try various compiler versions C++14 (-std=c++1y) and library -stdlib=libc++ (should it use dinkumware version of type_traits?) but the error persists.
Suggestions most welcome.
Paul

Building with Visual Studio 2010, MFC, and FFmpeg

I'm working on building a Windows MFC application in Visual Studio 2010 using FFmpeg and SDL. However, I can't get the project to build after creating an MFC project from scratch and including the FFmpeg development libraries (avcodec.lib, avdevice.lib, avformat.lib, etc.). I'm using the development build from Zeranoe FFmpeg. I have configured the following in the Project Properties:
Set VC++ Directories -> Include Directories (added the FFmpeg "include" directories)
Set VC++ Directories -> Library Directories (to the FFmpeg "lib" directory)
Set Linker -> Input -> Additional Dependencies (to include avcodec.lib, etc.)
For what it's worth, the build succeeds when I omit FFmpeg's "include\libavutil" include from the VC++ Directories -> Include Directories.
Below are some of the first build errors I'm receiving (I won't post all, since it's long). Any help would be appreciated.
ClCompile:
stdafx.cpp
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atltime.h(371): error C3861: '_mktime64': identifier not found
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atltime.h(386): error C3861: '_localtime64_s': identifier not found
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atltime.h(409): error C3861: '_gmtime64_s': identifier not found
c:\program files\microsoft sdks\windows\v7.0a\include\intsafe.h(144): warning C4005: 'INT8_MIN' : macro redefinition
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxtaskspane.h(279): error C2146: syntax error : missing ';' before identifier 'm_nLastAnimTime'
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxribboncategory.h(282): error C2146: syntax error : missing ';' before identifier 'm_ActiveTime'
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxdockingmanager.h(353): error C2146: syntax error : missing ';' before identifier 'm_clkLastTime'
Build FAILED.
I've referenced both of these articles, which were of help:
Visual Studio and libavcodec
Visual Studio and SDL
I think what you did is this. When you did your first 2 steps
Set VC++ Directories -> Include Directories (added the FFmpeg
"include" directories)
Set VC++ Directories -> Library Directories
(to the FFmpeg "lib" directory)
You have included them at the top of the list before MFC and ATL paths. Please move them to the bottom of the list using the up/down buttons. This should solve the problem
Have a look at Use FFmpeg in Visual Studio - it has a link to small Visual Studio 2010 project that builds against Zeranoe binaries.
Note that you need a inttypes.h file to succeed in building.
Your log shows issues with stdafx.cpp and this means that you have either search paths set wrong, or something is wrong in stdafx.h. Putting FFmpeg directories on top of search list might work out, however it might equally well break building for MFC part. I would rather have them on the bottom of the list, however the code itself should have the correct order of explicit #includes.

Errors when compiling library in command line

I am trying to compile this library: http://www.mega-nerd.com/SRC/win32.html . but I am having some trouble. Here's what happens:
C:\libsamplerate-0.1.8>make
1 file(s) copied.
1 file(s) copied.
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
link.exe /nologo /dll /incremental:no /libpath:""C:\Program Files (x86)\
Microsoft Visual Studio 10.0\Common7\IDE"\Lib" /pdb:"libsamplerate-0.pdb" /impli
b:".\libsamplerate-0.lib" /machine:I386 /out:"libsamplerate-0.dll" /def:".\Win32
\libsamplerate-0.def" ".\src\samplerate.obj" ".\src\src_linear.obj" ".\src\src
_zoh.obj" ".\src\src_sinc.obj"
LINK : fatal error LNK1181: cannot open input file 'Files.obj'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\BIN\link.exe"' : return code '0x49d'
Stop.
I run vcvars32.bat prior to attempting to compile, I think I have all the right folders in my path variable, but I'm new to this so I'm not entirely sure. What am I doing wrong?
You are having a quoting issue with the line:
/libpath:""C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE"\Lib"
Should be:
/libpath:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Lib"
You get error: "LINK : fatal error LNK1181: cannot open input file 'Files.obj'"
Because the linker thinks you are adding file "Files" as one of input libraries.
This comes from "C:\Program Files (x86)" (see the "Files"?) ;-)
Check if kb 815645 doesn't help:
You receive a "fatal error LNK1181" error message when you build a Managed C++ application
fatal error LNK1181: cannot open input file 'C:\Program.obj'
Scenario 2:
The linker error LNK1181 may also occur if you add an unqualified file to the Additional Dependencies project property, and that file does not exist in any of the search directories that are defined in the LIB environment variable or the /LIBPATH project property.
You may add the directory that contains library file to the LIBPATH to resolve the problem:
In Solution Explorer, right-click the project, and then click Properties.
In the Property Pages dialog box, expand Linker, and then click General.
In the Additional Library Directories field, specify the required library path.

Building/Using CppUnit Library on VS2010

I downloaded and compiled CppUnit to compile with Visual Studio 2010.
After the conversion, I could load the CppUnitLibraries, and it gives me cppunit.lib and cppunit_dll.lib/dll. After copying the headers and libs to a directory, I run this command to get a lot of errors.
I found the conflict of libraries as follows
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
However, the following command doesn't seem to work.
cl main.cpp complex.cpp testset.cpp /I"C:\CppUnit\include" /link /libpath:"C:\CppUnit\lib" cppunit.lib /NODEFAULTLIB:library
What's wrong with them?
This is the command that I used for compilation/link.
cl main.cpp complex.cpp testset.cpp /I"C:\CppUnit\include" /link /libpath:"C:\CppUnit\lib" cppunit.lib
This is the error message from VS2010.
cppunit.lib(TestResult.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL':
...
node###Z) already defined in LIBCMT.lib(typinfo.obj)
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:lib
rary
main.exe : fatal error LNK1169: one or more multiply defined symbols found
ADDED
The CppUnit provides older version of project file (dsw), so I needed to convert the file to 2010 solution project manually.
For the error, missing /MD for compilation was the source of the problem. For other compilation warning, I needed to add /EHsc parameter.
cl /EHsc /MD /c /I"./CppUnit/include" main.cpp testset.cpp complex.cpp
link /libpath:"CppUnit/lib" main.obj testset.obj complex.obj cppunit.lib /out:cpptest_static.exe
link /libpath:"CppUnit/lib" main.obj testset.obj complex.obj cppunit_dll.lib /out:cpptest_dynamic.exe
seems like you compiled CppUnit in debug mode, weheras you're now compiling your current files in release mode. Those should not be mixed, and that's what the compiler is telling you.
The quickest way to resolve this would probably be to use a VS project, and check it's settings against the project used to compile CppUnit.
on your edit: you're also mixing runtime libraries (eg check that both are compiled using the /MD switch aka Multi-Threaded DLL)
I upgraded my CPPUNIT projects to visual studio 2010 and had to manually fix it.
The problem in the build was in the final actions where the output files are copied.
For the cppunit_dll project, one of the custom commands is:
copy "$(TargetPath)" ..\..\lib\$(TargetName).dll
copy "$(TargetDir)$(TargetName).lib" ..\..\lib\$(TargetName).lib
$(TargetName) is "cppunit_dll".
This conflicts with what we're actually building: if you look at the Linker options, you see that the output file name is "cppunitd_dll.dll".
The solution I used is to go to ConfigurationPropertys\General, and change "Target Name" from $(ProjectName) to"cppunitd_dll".
I had to to a similar solution for the cppunit project.
read INSTALL-VS.Net2008.txt in the cppunit folder after checking out the source code from SVN.
basically:
there is a visual studio solution under the examples folder.
that being said... i still can't get it to build without errors on vs2010 after converting it. i get 'cmd.exe' failed and failures to copy dlls.

Resources