I'm attempting to work with openGL in visual studio 2010, and so far my code looks like so
#include<gl\GLU.h>
#include<gl\GL.h>
int main(int argc, char**argv){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(640, 480);
glutCreateWindow("Simple GLUT application");
glutMainLoop();
}
Visual studio is not recognizing any of the glut methods and is throwing errors such as "glutInit not recognized"
I know it is some error with how I linked the libraries, but I am new at this, so please be kind. Anyone know how to get this example working properly?
You need to include the glut headers. Glut is the "GL utility toolkit" and is a separate library built on top of OpenGL, not part of OpenGL itself.
If you have them in the same directory as your other includes, it would read
#include<gl\GLUT.h>
For more info: here
Did you make sure that you copied glut32.dll to %windir%\system and glut.h to %VSdir%\VC\include\GL and glut32.lib to %VSdir%\lib? If you did it right then you shall see the Open GL methods in the intellisense.
Related
so i don't know a lot for VS2015
i downlode it because i want to use it in my University to use OpenGL
so i have this problem and i didn't fine any way to fix it
first of all i install the program in disk D:
i have made a project in C and D and got the same problem
i try to run it without debug and without cod
"Severity Code Description Project File Line Suppression State
Error LNK1104 cannot open file 'ucrtd.lib' ConsoleApplication2 D:\Users\Anmar\documents\visual studio 2015\Projects\ConsoleApplication2\ConsoleApplication2\LINK 1
"
this is photo for the problem when i add some code and run it
http://screencast.com/t/znmUrht6vyg
the code was
#include <glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glClearColor(1.0, 1.0, 1.0, 0.0);
glutDisplayFunc(display);
glutMainLoop();
}
so any way to fix this ?
I think your question may be similar to this one:
How to I update my C++ project in Visual Studio 2015 to use the new Universal CRT?
I had to do a couple things to get older C++ projects to work with VS2015.
First, I had to make sure I installed MFC as part of VS2015.
Second, I needed to add to my LibraryPath, for my 32-bit project:
$(UniversalCRT_LibraryPath_x86)
So now my vcxproj file has this for its LibraryPath
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\WinDDK\7600.16385.1\lib\wxp\i386;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir_71A)lib;$(UniversalCRT_LibraryPath_x86)</LibraryPath>
Third, I had to refresh my understanding of the variety of C Run-Time libraries with VS2015, since they have changed a little bit. Here's the link to CRT Library Features on MSDN, which explains how all the switches affect what in VS2015:
https://msdn.microsoft.com/en-us/library/abx4dbyh.aspx
Some of my vcxproj switches were mismatched with what MSDN said. It took a little effort to get them all straightened out.
Then I realized I had only done my Debug configuration. I had to also make all the changes all over again to my Release configuration. Good safety tip.
Hope that helps!
I have a header file with the following code:
Microsoft::WRL:ComPtr<ID3D11Device2> m_device;
inside a class definition. Visual Studio 2013 is saying that Microsoft is not a namespace, if I take the code and cut it out and put it in another class in another file unchanged it works just fine!
Any ideas?
Philip
EDIT: All of a sudden (without me having changed anything) Intelissense now accepts Microsoft::WRL::ComPtry as valid but when I compile it still gives me errors that it does not exists.
You need to
#include <wrl.h>
or
#include <wrl/client.h>
To get Microsoft::WRL::ComPtr in your module.
When you say "Visual Studio 2013 is saying that Microsoft is not a namespace" do you mean you get a compiler error or is just Intellisense? When dealing with headers, Intellisense can get a bit out of sync until you build again. For example:
//Test.h
class A { Microsoft::WRL::ComPtr<T> a; };
//Test.cpp
#include <wrl/client.h>
#include "Test.h"
If you just added the #include <wrl/client.h> to the Test.cpp, Intellisense might not know yet it is in scope for the header. It's perfectly valid C++ already, but a better practice is to include in your headers the ones it needs like:
//Test.h
#pragma once
#include <wrl/client.h>
class A { Microsoft::WRL::ComPtr<T> a; };
The other way this sync issue can manifest itself is if you are doing:
//Test.h
class A { Microsoft::WRL::ComPtr<T> a; };
//Test.cpp
#include "pch.h"
#include "Test.h"
//pch.h
#include <wrl/client.h>
Again, fully valid C++ that will build. Intellisense knows it works when you build, but might not until then.
Note: WRL is traditional C++ and is not using C++/CX language extensions. They both exist to make it easier to consume WinRT APIs from C++, and you will see the Microsoft::WRL::ComPtr used inside C++/CX applications when dealing with non-WinRT COM APIs like Direct3D. And you can mix C++/CX with WRL in the same application taking advantage of the fact that you can use reinterpret_cast<> between C++/CX ref ^ and ABI COM pointers. You can use Microsoft::WRL::ComPtr in old-school Windows desktop apps on Windows 7 or Windows Vista too.
With all that said, WRL and C++/CX are two distinct things.
Update: For consuming Windows Runtime APIs, you can also use C++/WinRT which is also 'standard' C++ without any need for the C++/CX extensions. See Microsoft Docs. You can use Microsoft::WRL::ComPtr for C++/WinRT applications, or you can use their variant wrl::com_ptr
I would like to run my Objective-C code inside Xcode, but not for the iPhone or Mac. I want to write programs to solve the challenges from Project Euler, without starting up the simulator. I am using NSLog() to display my results, and that's all I need.
How can I do this? I checked everywhere but all I found were questions about how to run Objective-C outside of Xcode and so on.
If I'm understanding right, you want to create a "Command-Line Tool", one of the options under the Mac OS X templates:
That'll give you a project containing just one code file, main.m:
// main.m
// Project Euler Puzzle #N
//
// Created by pnizzle on 8/7/12.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
#autoreleasepool {
}
return 0;
}
It's linked against Foundation and compiled as ObjC, so you can do pretty much anything you would do in a GUI app (except the GUI parts, of course), including creating your own classes. main() is the entry point for your program; just put whatever you want to do inside that #autoreleasepool block.
An alternative to using the Command Line Tool option in Xcode is the CodeRunner app, available in the Mac App Store. CodeRunner allows you to run short snippets of Objective-C code without the overhead of Xcode.
CodeRunner also supports a number of other languages: C, Java, JavaScript, Lua, Perl, PHP etc
CodeRunner currently costs about $10, I have found it to be very useful to quickly test short snippets of code in a number of languages.
I believe you will need to install the Command Line Tools package from Xcode -> Preferences -> Downloads for CodeRunner to use.
http://krillapps.com/coderunner/
Choosing "Command-Line Tool"will do the job for you. You will see the output in the bottom when you run the code.
I'm getting this linker error when compiling wxWidgets in Visual Studio 2010.
msvcrt.lib(wcrtexew.obj) : error LNK2001: unresolved external symbol _wWinMain#16
Now here's the problem. The entry point for wxWidgets is this macro:
IMPLEMENT_APP(MyApp)
Which means I don't use wWinMain() as an entry.
I've tried disabling the entry point when I compile (/NOENTRY), but no dice. Nothing seems to work because if I define wWinMain(), then wxWidgets won't start because the entry is IMPLEMENT_APP.
I only receive this error when I compile as static. If I don't compile as static I'll have to supply the DLLs: msvcp100d.dll and msvcr100d.dll on Windows Server 2008 (and maybe more DLLs on older versions of Windows that don't have the library installed).
Now I understand I am linking again the debug library, but it shouldn't matter if I link again the release because I should receive the same error (unresolved external symbol _wWinMain#16).
Any solutions?
When you link to static libraries you have to ensure that the libraries were built with the EXACT SAME parameters as you used to build the application code.
So: go through all the compiler options for the library build and the application build and ensure that they match. Also, make sure that the application build is linking to the static libraries there were built using the configuration you have matched.
It is a pain! You have to decide wether you want to deal with this problem, or the problem of installing the correct DLLs on the target machine. Either way, you have to solve configuration management problems.
In your particular problem, I see the linker is looking for _wWinMain#16 which suggests that you have build your application code with unicode switched on, but are linking to a non unicode static library.
First compile wxWidgets' Library (wxWidgets\build\msw) all with the same settings you have in your project. So I enable "/MT", "Use MFC in a Static Library", and output the projects as "Release". Same exact settings on my wxWidgets' application I coded.
Now Comment out:
IMPLEMENT_APP(MyApp)
And use this for your entry point:
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE prevInstance, LPWSTR lpCmdLine, int nShowCmd)
{
char *buf;
buf = new char[wcslen(lpCmdLine) + 1];
wcstombs(buf, lpCmdLine, wcslen(lpCmdLine) +1);
wxApp::SetInstance( new MyApp());
wxEntry(hInstance, prevInstance, buf, nShowCmd);
wxEntryCleanup();
}
Do you have
IMPLEMENT_APP(MyApp)
In a .cpp file? It is typically in the accompanying file to where IMPLEMENT_APP(MyApp) is located.
I am using wxWidgets as a static library and that is what I do to compile.
I had the same problem after I changed my project's character set to unicode. My project uses multi-threaded Debug DLL (/MDd). Above workaround worked for me, too, but I wanted to find out what was actually causing the problem and use IMPLEMENT_APP.
After I changed "Use of MFC" to "Use Standard Windows Libraries" I was able to successfully build the project.
At the moment CUDA already recognizes a key CUDA C/C++ function such as cudaMalloc, cudaFree, cudaEventCreate, etc.
It also recognizes certain types like dim3 and cudaEvent_t.
However, it doesn't recognize other functions and types such as the texture template, the __syncthreads functions, or the atomicCAS function.
Everything compiles just fine, but I'm tired of seeing red underlinings all over the place and I want to the see the example parameters displayed when you type in any recognizable function.
How do I get VS to catch these functions?
You could create a dummy #include file of the following form:
#pragma once
#ifdef __INTELLISENSE__
void __syncthreads();
...
#endif
This should hide the fake prototypes from the CUDA and Visual C++ compilers, but still make them visible to IntelliSense.
Source for __INTELLISENSE__ macro: http://blogs.msdn.com/b/vcblog/archive/2011/03/29/10146895.aspx
You need to add CUDA-specific keywords like __syncthreads to the usertype.dat file for visual studio. An example usertype.dat file is included with the NVIDIA CUDA SDK. You also need to make sure that visual studio recognizes .cu files as c/c++ files as described in this post:
Note however that where that post uses $(CUDA_INC_PATH), with recent versions of CUDA you should use $(CUDA_PATH)/include.
Also, I would recommend Visual Assist X -- not free, but worth the money -- to improve intellisense. It works well with CUDA if you follow these instructions:
http://www.wholetomato.com/forum/topic.asp?TOPIC_ID=5481
http://forums.nvidia.com/index.php?showtopic=53690