SuperBible 6th edition sb6_d32.lib not found? - c++

I'm learning OpenGL using superbible 6th edition and while compiling this code:
#include <iostream>
#include "sb6.h"
class my_application : public sb6::application
{
public:
void render(double currentTime)
{
static const GLfloat red[] = { 1.0f,0.0f,0.0f,1.0f };
glClearBufferfv(GL_COLOR, 0, red);
}
};
DECLARE_MAIN(my_application);
I'm getting a linking errors saying cannot open sb6_d32.lib
I searched the entire sb6 directory there is no sb6_d32.lib file available for it to open so that i can link it? Am i missing something?
Edit: 2 Unresolved externals
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main##YAHXZ) OpenGL_learning E:\C++\Learning\OpenGL\OpenGL_learning\OpenGL_learning\MSVCRTD.lib(exe_main.obj) 1
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol __imp____iob_func referenced in function __glfwPlatformOpenWindow OpenGL_learning E:\C++\Learning\OpenGL\OpenGL_learning\OpenGL_learning\GLFW_d32.lib(win32_window.obj) 1

You have to build it first. See HOWTOBUILD.txt file in your examples folder root:
Windows / Microsoft Visual Studio 2010:
Project files are included in the source archive for Visual Studio
2010. These will work with Professional (all tiers) and Express editions. Newer versions of Visual Studio should import them just
fine, but this is not extensively tested. Simply open the sb6.sln file
in Visual Studio and hit build (F7). Evertything will build and you'll
end up with binaries in the 'bin' directory.
Update: Unresolved externals.
LNK2019 unresolved external symbol _main referenced in
function "int __cdecl invoke_main(void)" (?invoke_main##YAHXZ)
Lets see DECLARE_MAIN macro implementation in the sb6.h:
#if defined _WIN32
#define DECLARE_MAIN(a) \
sb6::application *app = 0; \
int CALLBACK WinMain(HINSTANCE hInstance, \
HINSTANCE hPrevInstance, \
LPSTR lpCmdLine, \
int nCmdShow) \
{ \
a *app = new a; \
app->run(app); \
delete app; \
return 0; \
}
If you want to use this macro, your program should be compiled as windows application (/SYBSYSTEM:WINDOWS), you are creating console application which is not supported. Change subsystem in your project settings (Linker/System).
LNK2019 unresolved external symbol __imp____iob_func
referenced in function __glfwPlatformOpenWindow
See this for the ways to solve that problem. In short you have to recompile all used static libraries with your version of Visual Studio.

Related

libconfig- unresolved external on visual studio 2010

I'm trying to compile a code with the libConfig library on Windows, in Visual Studio.
This is the code:
#include "libconfig.hh"
using namespace libconfig;
int main(int argc, char * argv[])
{
Config cfg;
return 0;
}
I downloaded the library from here. On Additional Include Directories, I added the folder with all the sources and headers.
The error I get for that code is:
1>LibConfigTest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall libconfig::Config::~Config(void)" (__imp_??1Config#libconfig##UAE#XZ) referenced in function _main
1>LibConfigTest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall libconfig::Config::Config(void)" (__imp_??0Config#libconfig##QAE#XZ) referenced in function _main
1>c:\users\***\visual studio 2010\Projects\LibConfigTest\Debug\LibConfigTest.exe : fatal error LNK1120: 2 unresolved externals
I also compiled the example code and it succeeded, so I looked at the properties, Additional Include Files and compared it to mine and it was the same.
I can't see any other differences between the codes.
I don't know what am I missing and be happy for some guidance on that one.
You'll have to also link the library. Maybe the headers have in them some pragma link but even in that case you'll have to include the path for the library somehow. Look for Library Directories, C/C++ Additional Include Directories... if there is no pragma link you'll have to add the lib explicitly at Linker | Input | Additional Dependencies. The path to the library will have to be specified at VC Directories | Library Directories.

How to build a static Clucene library to avoid any linker errors

I work with Windovs and I need to build a static CLucene library. I downloaded the latest source code and build them into Visual Studio 2010 Project through CMake-gui 3.4.3. When building I used a flag BUILD_STATIC_LIBRARIES = true. I successfully built two libraries: clucene-core-statics and clucene-shared-static. However, when I run the test project cl-test-static occurs a lot of linker errors. The same thing happens when I add these libraries in another test project.
Error Example:
Error 1 error LNK2019: unresolved external symbol
"__declspec(dllimport) public: static wchar_t * __cdecl
lucene::queryParser::QueryParser::escape(wchar_t const *)"
(__imp_?escape#QueryParser#queryParser#lucene##SAPA_WPB_W#Z)
referenced in function "public: void __thiscall Main::Start(void)"
(?Start#Main##QAEXXZ) c:\Users\user\documents\visual studio
2010\Projects\TestClucene\TestClucene\Main.obj TestClucene
Does anyone have any experience in building static CLucene libraries?

Installing and working with FLTK on Visual Studio 2012

My machine in Windows 7 32-bit and my compiler for C++ is Visual Studio 2012 so first I downloaded FLTK from here (http://www.stroustrup.com/Programming/FLTK/) and then I did the works as follows has wanted me:
I. Unzip the downloaded file and open the main folder, fltk-l.l.? In a
Visual C++ folder (e.g., vc2005 or vcnet), open fltk.dsw. If asked about
updating old project files, choose Yes to All.
PS: My compiler is vc2012 instead of vc2005 and there wasn't any file named fltk.dsw in vc2005 or vcnet folders, so I chose the fltk.sln from vcnet and installed it. There were some failing when installing but it finished finally!
From the Build menu, choose Build Solution. This may take a few minutes.
The source code is being compiled into static link libraries so that
you do not have to recompile the FLTK source code any time you make
a new project. When the process has finished , close Visual Studio.
From the main FLTK directory open the lib folder. Copy (not just
move/drag) all the .lib files except README.lib (there should be
scven) into C:\Prograrn Files\Microsoft Visual Studio\Vc\lib.
Go back to the FLTK main directory and copy the FL folder into
C:\Program Files\Microsoft Visual Studio\Vc\include.
Create a new project in Visual Studio with one change to the usual procedure:
create a "\Vin32 project" instead of a "console application" when
choosing your project type. Be sure to create an "empty project"; otherwise,
some "software wizard" will add a lot of stuff to your project that
you are unlikely to need or understand.
In Visual Studio, choose Project from the main (top) menu, and from
the drop-down menu choose Properties.
In the Properties dialog box, in the left menu, click the Linker folder.
This expands a sub-menu. In this sub-menu, click Input. In the Additional
Dependencies text field on the right, enter the following text:
fltkd.lib wsock32.lib comctl32.lib fltkjpegd.lib fltkimagesd.lib
[The following step may be lIImecessary because il is now the default.]
In the Ignore Specific Library text field, enter the following text:
libcd.lib
[This step may be unnecessary because /MDd is now the default.] In the
left menu of the same Properties window, dick C/C++ to expand a different
sub-menu. Click the Code Generation sub-menu item. In the right
menu, change the Runtime Library drop-down to Multi-threaded
Debug DLL (/MDd). Click OK to close the Properties window.
I this step I added a new item to that newly created project (I named that project testv.cpp) and pasted this simple code for testing the FLTK:
#include <FL/Fl.h>
#include <FL/Fl_box.h>
#include <FL/Fl_Window.h>
//***************************
int main()
{
FI_Window window(200, 200, "Window title");
FL_Box box(O,O,200,200, "Hey, I mean, He llo, World! ");
window.show();
return Fl::run();
}
After running this project (pressing F5), 11 errors appeared! They are in bellow:
Error 1 error LNK2019: unresolved external symbol "public: static int
__cdecl Fl::run(void)" (?run#Fl##SAHXZ) referenced in function _main C:\Users\CS\documents\visual studio 2012\Projects\testv\testv\testv.obj
Error 2 error LNK2019: unresolved external symbol "protected:
__thiscall Fl_Widget::Fl_Widget(int,int,int,int,char const *)" (??0Fl_Widget##IAE#HHHHPBD#Z) referenced in function "public:
__thiscall Fl_Box::Fl_Box(int,int,int,int,char const *)" (??0Fl_Box##QAE#HHHHPBD#Z) C:\Users\CS\documents\visual studio
2012\Projects\testv\testv\testv.obj
Error 3 error LNK2019: unresolved external symbol "public: virtual
__thiscall Fl_Widget::~Fl_Widget(void)" (??1Fl_Widget##UAE#XZ) referenced in function "public: virtual __thiscall
Fl_Box::~Fl_Box(void)"
(??1Fl_Box##UAE#XZ) C:\Users\CS\documents\visual studio
2012\Projects\testv\testv\testv.obj
Error 4 error LNK2001: unresolved external symbol "public: virtual
void __thiscall Fl_Widget::resize(int,int,int,int)"
(?resize#Fl_Widget##UAEXHHHH#Z) C:\Users\CS\documents\visual studio
2012\Projects\testv\testv\testv.obj
Error 5 error LNK2001: unresolved external symbol "protected: virtual
void __thiscall Fl_Box::draw(void)"
(?draw#Fl_Box##MAEXXZ) C:\Users\CS\documents\visual studio
2012\Projects\testv\testv\testv.obj
Error 6 error LNK2001: unresolved external symbol "public: virtual int
__thiscall Fl_Box::handle(int)" (?handle#Fl_Box##UAEHH#Z) C:\Users\CS\documents\visual studio
2012\Projects\testv\testv\testv.obj
Error 7 error LNK2019: unresolved external symbol "public: __thiscall
Fl_Window::Fl_Window(int,int,char const *)"
(??0Fl_Window##QAE#HHPBD#Z) referenced in function
_main C:\Users\CS\documents\visual studio 2012\Projects\testv\testv\testv.obj
Error 8 error LNK2019: unresolved external symbol "public: virtual
__thiscall Fl_Window::~Fl_Window(void)" (??1Fl_Window##UAE#XZ) referenced in function _main C:\Users\CS\documents\visual studio
2012\Projects\testv\testv\testv.obj
Error 9 error LNK2019: unresolved external symbol "public: virtual
void __thiscall Fl_Window::show(void)" (?show#Fl_Window##UAEXXZ)
referenced in function _main C:\Users\CS\documents\visual studio
2012\Projects\testv\testv\testv.obj
Error 10 error LNK2019: unresolved external symbol WinMain#16
referenced in function __tmainCRTStartup C:\Users\CS\documents\visual
studio 2012\Projects\testv\testv\MSVCRTD.lib(crtexew.obj)
Error 11 error LNK1120: 10 unresolved
externals C:\Users\CS\documents\visual studio
2012\Projects\testv\Debug\testv.exe
I think the problem is to do with the creating the project. After I created an empty project from Win32 Project I clicked on Add new item and chose the .cpp type. I don't know was it correct or not.
Any idea for fixing the problem?
You are getting that error because you are entering all the library names on one line without a separator. It is taking the whole list as one library. Click on the ellipsis then enter each library name separated by a newline.
Instead of wsock32.lib, use ws2_32.lib
You are getting that error because you are entering all the library
names on one line without a separator. It is taking the whole list as
one library. Click on the ellipsis then enter each library name
separated by a newline.
Instead of wsock32.lib, use ws2_32.lib
Just to add. To Separate each library, put a semicolon after each library name (ex. libraryname.lib; libraryname.lib) or just press enter on the text box to go to the next line so Visual Studio will read it as next line and anything you enter to it will consider it as a library name.
Example:
libraryname.lib - Now, press enter so it will go to the next line, VS will recognize at a library name.
libraryname.lib - This is the next line and your new library
I am studying C++ and using Microsoft Visual Studio 2015 ^_^

Can't link GLFW C++; Added the .dll, .h, .lib, but still getting LNK2019

I've added the .dll to Windows/System32, the .lib to VS/lib, and the .h to the VS/include.
All that would be left is linking it through the project. This is what I have:
#include <glfw.h>
int main(void)
{
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
if (!glfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_WINDOW))
return -1;
/* Loop until the user closes the window */
while (glfwGetWindowParam(GLFW_OPENED))
{
/* Render here */
/* Swap front and back buffers and process events */
glfwSwapBuffers();
}
return 0;
}
1>Main.obj : error LNK2019: unresolved external symbol _glfwSwapBuffers referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwGetWindowParam referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwOpenWindow referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwInit referenced in function _main
1>C:\Users\Danny\documents\visual studio 2010\Projects\OGL2\Debug\OGL2.exe : fatal error LNK1120: 4 unresolved externals
I've went to Project > Properties > Configuration Properties > Linker >
Added the following to Additional Dependencies:
opengl32.lib;GLFW.lib;glu32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
And for good measure, I also set Ignore All Default Libraries to "No".
I know I should have linked: opengl32.lib, GLFW.lib, glu32.lib, kernel32.lib and user32.lib
Unfortunately, the LNK 2019 problems persist. Really am unsure why. All help is greatly appreciated.
The external names indicate that your project is building for a 64-bit target (32-bit DLL exports generally have the #nn suffix used by the stdcall calling convention). I'll bet your libraries are build for a 32-bit target.
Change the project settings to Win32 instead of x64.
I guessed incorrectly - the unresolved external symbols such as _glfwSwapBuffers indicate that you're building for a 32-bit target. When building for a 64-bit target, the external names do not get decorated with an underscore.
But the basic solution is the same - make sure that the target that is being built is the same as the target that the libraries you have are. So if you've downloaded the 64-bit GLFW libraries, make sure your VS project is building for a Win64 target.
I was able to compile and link your test program after extracting the 64-bit GLFW binary distribution into c:\temp:
C:\temp>cl /I c:\temp\glfw-2.7.7.bin.WIN64\include\GL test.cpp c:\temp\glfw-2.7.7.bin.WIN64\lib-msvc110\GLFWDLL.lib
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.50727.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
test.cpp
Microsoft (R) Incremental Linker Version 11.00.50727.1
Copyright (C) Microsoft Corporation. All rights reserved.
/out:test.exe
test.obj
c:\temp\glfw-2.7.7.bin.WIN64\lib-msvc110\GLFWDLL.lib
C:\temp>
I got exactly the same error message . I notice there is no .lib file in my glfw folder ,Because I download source package, You need download pre-compile binaries version,
Then I got it to work;

Linking with glog library

I'm trying to use the glog logging library (LINK).
In VS2012 (I'm on Windows 8 Professional 64-bit (Japanese)), I create an empty solution with a single main.cpp file like the one in the documentation (LINK).
Also I import the glog project inside the solution (either the dll one or the static library one) and set the project dependency.
To avoid some errors I have to comment out line 97 from port.h:
/* In windows-land, hash<> is called hash_compare<> (from xhash.h) */
#define hash hash_compare
While glog compiles, the main application gives me unresolved external symbol erros (with both dll and static version).
1>main.obj : error LNK2019: 未解決の外部シンボル "void __cdecl google::InitGoogleLogging(char const *)" (?InitGoogleLogging#google##YAXPBD#Z) が関数 _main で参照されました。
1>main.obj : error LNK2019: 未解決の外部シンボル "public: __thiscall google::LogMessage::LogMessage(char const *,int)" (??0LogMessage#google##QAE#PBDH#Z) が関数 _main で参照されました。
1>main.obj : error LNK2019: 未解決の外部シンボル "public: __thiscall google::LogMessage::~LogMessage(void)" (??1LogMessage#google##QAE#XZ) が関数 _main で参照されました。
I'm compiling as Win32.
If I check the debug folder it actually contains the dll+lib or static lib file.
I also tried linking to the library manually without using the visual studio dependency system, but it's the same.
I've built glog for MSVS2012 from trunk (little patch mentioned in header already presented here, as i know), so it works for me.
Looks like your dependency description of glog library is missing.
Can you add windows-specific
#pragma comment(lib, "path_to_glog_from_project_dir.lib")
to one of your project files, for example, directly into main.cpp and test it.