Compiling the Canon SDK on macOS - c++

I'm trying to compile a very basic program (for the first time) on macOS. The program was written on windows with the help of the Canon SDK. This SDK is available for Windows as well as for macOS. There is however an issue I'm coming against. The SDK consists of 3 header files and a linker file ( .lib for windows and .framework for mac). As I never worked with macOS I first had to figure out how to link the .framework file.
OSX How to compile a framework using GCC/G++ sitting in a current working directory or subdirectory C/C++
This is the solution I found here.
However, I still run into an issue. In one of the files (EDSDK.h) there is an include of windows.h.
Actual code:
#ifdef __MACOS__
#include <CoreFoundation/CoreFoundation.h>
#else
#include <windows.h> <--Error
#endif
This include gives me an error as there is no window.h on the macOS. After some searching, I came across this question:
Where can I get windows.h for Mac?
Where the answer suggests making a dummy windows.h and one by one satisfy the missing definitions. This however was impossible as the SDK uses too much definitions from windows.h ( and other files included in the windows.h ) to be viable.
How do I go about compiling my program that uses the Canon SDK. Do I setup a dual boot setup and link to the actual windows.h?

Related

Installing OpenGL and compiling with command line on Windows

So there is the problem: when I compile #include <GL/gl.h> or #include <GL/glu.h> error occurs: no such file or directory. I updated NVidia drivers but error stays.
I have been struggling in setting up OpenGL without GLUT. I have read countless tutorials, but all of them are for Microsoft Visual C++, which requires placing gl.h in this IDE internal include folder. And I am trying to using only command line to compile winapi applications.
What dlls should I download and where to place them?
In Windows, OpenGL is provided as a static library, you do not need to get any DLLs (your graphics driver will provide OpenGL extensions). GL.h and GLU.h are included in the Windows SDK, along with OpenGL32.lib and GLU32.lib. However, if you want to use anything other than OpenGL 1.1., you will need to get wglext.h and glext.h from Khronos. Your driver will provide the extension prototypes, which you get using wglGetProcAddress (this function is linked in with OpenGL32.lib).

Where can I get windows.h for Mac?

I'm trying to compile a program on MacOSX that I originally wrote on a Windows OS. The program is a large C++ program with the OpenGL API among other things, totaling very many directories and files.
The compilation process at first had a problem with OpenGL for the Mac so I downloaded all the command line utilities of OpenGL for it to work. But as you might imagine, each C file within the OpenGL download had many preprocessors, each of which I in turn had to downloaded the dependencies for.
However, I have remaining one critical step: I receive a fatal error saying that windows.h file is not found. This seems something inherent to the Windows system (the windows.h file is nowhere to be found in my huge list of directories for the program), and the Mac does not seem to have an equivalent for windows.h (http://cboard.cprogramming.com/c-programming/96087-windows-h-mac.html).
Am I out of luck trying to compile this program for the Mac or can something be salvaged?
One thing you can do is create a dummy file called windows.h to satisfy the #include directive, then track down the missing typedefs, #defines, etc. one-by-one by looking at the compiler error log.
Windows.h is monolithic and includes about a hundred other Windows headers, but your program is not going to need all of those definitions. This assumes you are not using the Windows API directly, and only using simple things like DWORD. If your software is built using a framework like GLUT or GLFW that is entirely possible, but if you directly interface with WGL, you are going to have a lot of work ahead of you.
windows.h is provided by the Windows SDK, and implemented by the Windows OS itself.
You need to rewrite the program to not use Windows APIs.
Good luck.
You cannot get Windows.h for mac, it is Windows OS specific.
There are many alternatives to functions used in Windows.h on the other hand.

Setting up Opengl for Borlandc++

I have copied the glut.h file in c:/turbo/tc/include/ directory and glut32.dll in c:/windows/System32/.
After this what should I do ?
your path implies old Borland Turbo C++ 3.1 to me
which was the old MS-DOS C++ IDE (similar to Borland TP 7.0 pascal IDE)
in which you can not have classic 32bit OpenGL
there were some 16bit MS-DOS versions of GL+GLUT compatible ports of glut+gl libs.
so unless you do not have them then it will not work no matter you do
if you do then read the provided readme.txt or whatever to see how to use it
there were some tutorials on them but I strongly doubt you will find them on the internet
because most of old programing portals is off-line and stuff lost forever ...
if you have newer compiler like Borland C++ BCC 5.0 or newer
then just include headers
link lib files for used dll's for example:
#include "my_GL_headers\\glut.h"
#pragma link "my_GL_headers\\glut.lib"
use implib tool if you do not have them or are incompatible
because most provided libs are for MSVC++
which are incompatible with standard Intel object format
for more info see difference between COMF and OMF
some header files already link their lib files so do this only if you have unresolved externals ...
If you use IDE like Borland C++ builder 1,2,3,4,5,6 or Developer Studio 2006 Turbo C++
then look at this answer of mine: How to render an openGL frame in C++ builder?
all the headers and libs are included in IDE ...
PS this is how mine usual GL includes look like in BDS2006 projects
#include <windows.h>
#include <jpeg.hpp>
#include <math.h>
#define GLEW_STATIC
#include "gl\glew.c"
#include "gl\gl.h"
#include "gl\glu.h"
#include "gl\glext.h"
#include "gl\wglext.h"
#include "gl\glut.h"
where gl is project source local folder
including all headers/objs/libs ...
the only lib you need is glut.lib (if you want to use glut)
GLEW can be either as lib/dll/obj or as C++ source code
I prefer the C++ source version under borland/embarcadero

'glGenBuffers' was not declared in this scope. Windows 7. Qt 4.8.1

'glGenBuffers' was not declared in this scope
thats the error which I get after trying to use that metod. How to add appropriate libs or sth else and what i should add and how. I'm using win 7 and qt 4.8.1. I've read about GLEW but I don't know how to add it to windows or qt.
It's a FAQ. Windows defines the OpenGL ABI (B for binary interface) only up to version OpenGL-1.1 – anything beyond that must be loaded at runtime using the extension loading mechanism. Most easily done by using a wrapper library like GLEW.
I've read about GLEW but I don't know how to add it to windows or qt.
If you want to use any 3rd party library, you've to learn how to do that. It boils down to install the library and its header in some system wide directory, but outside the regular compiler tree, and add those directories to the include and library search paths.
I use this code for including GLEW and Glut for cross-platform development:
#ifndef GL_H
#define GL_H
#ifdef __APPLE__
#include <GL/glew.h>
#include <GLUT/glut.h>
#else
#include <GL/glew.h>
#include <GL/glut.h>
#endif
#endif // GL_H
I encapsulate that into a file called gl.h and include that anywhere I need an OpenGL context. You will need to research how to install GLEW on your system. Make sure that you install the correct build of GLEW for your compiler. If you use Visual C++ 2010 or MinGW, it will be slightly different as far as where to put the libs and include files. You could always build from source too, but that is a more advanced route.
If you would like some sample code on how to get started with Qt and OpenGL, I've got a repository on Bitbucket with some code that I wrote for an OpenGL programming class here: https://bitbucket.org/pcmantinker/csc-4356/src/2843c59fa06d0f99d1ba90bf8e328cbb10b1cfb2?at=master

atlbase.h and different versions of VC CRT

I have a C++/CLI project created with Visual Studio 2010 that targets .NET Framework 3.5 and PlatformToolset v90. Initially it requests the VC CRT of version 9.0.21022.8, but if I include atlbase.h header then it requests the VC CRT of version 9.0.30729.6161.
Why does this happen? And how can I make it to target 9.0.30729.6161 without including atlbase.h?
I tried to define macroses _BIND_TO_CURRENT_CRT_VERSION=1 and _BIND_TO_CURRENT_VCLIBS_VERSION=1 but this didn't help.
The version is set by vc/include/crtassem.h, near the bottom you can see:
#ifndef _CRT_ASSEMBLY_VERSION
#if _BIND_TO_CURRENT_CRT_VERSION
#define _CRT_ASSEMBLY_VERSION "9.0.30729.6161"
#else
#define _CRT_ASSEMBLY_VERSION "9.0.21022.8"
#endif
#endif
So the rule is that you can explicitly override the version by #defining _CRT_ASSEMBLY_VERSION. Don't do that. As you noted in your question, #defining _BIND_TO_CURRENT_CRT_VERSION to 1 gets you the version string you want.
Having a problem with this in a C++/CLI project is possible. You can compile C++/CLI code without ever #including any of the CRT include files. So you'll end up with a default version which, ironically, is defaulted by the linker to its own version of the CRT. So a workaround is to explicitly put #include <crtassem.h> in one of your source code files. #including atlbase.h would do that too since it does include CRT headers but of course is the big hammer approach.
Additional troubleshooting is available from Project + Properties, C/C++, Advanced, Show Includes = Yes. You'll see a trace of all the #include files getting included in the Output window.
Beware that you'll now have the additional burden to ensure that the up-to-date version of msvcr90.dll gets deployed on the user's machine. Your program will fail to start if it is missing or old.