because I habe problems installing the DirectX SDK June (11), I read that Windows 8.1 users already have the DirectX 11 SDK integrated - in the Windows-SDK. But nevertheless, I could not get the info (even not from MCs article "Where is the DirectX SDK) if this SDK only offers the possibility to write DirectX-Apps (Win 8-Apps). If it also supports writing normal desktop-programs:
Do you know how I can set up a normal Win32-Project using DirectX from the Windows-SDK.
#pragma region COM
#include <guiddef.h>
#include <OCIdl.h>
#include <Unknwn.h>
#include <Objbase.h>
#pragma comment(lib, "Ole32.lib")
#include <OleCtl.h>
#pragma comment(lib, "OleAut32.lib")
#include <comutil.h>
#ifdef _DEBUG
#pragma comment(lib, "comsuppwd.lib")
#else
#pragma comment(lib, "comsuppw.lib")
#endif
#pragma region WIC
#include <wincodecsdk.h>
#include <wincodec.h>
#pragma comment(lib, "windowscodecs.lib")
#pragma endregion
#pragma region D2D
#include <d2d1.h>
#include <d2dbasetypes.h>
#include <d2d1helper.h>
#include <d2d1_1.h>
#include <d2d1_1helper.h>
#include <d2d1_2.h>
#include <d2d1_2helper.h>
#include <d2d1effects.h>
#include <d2d1effecthelpers.h>
#include <d2d1effectauthor.h>
#pragma comment(lib, "d2d1.lib")
#pragma endregion
#pragma region DWrite
#include <dwrite.h>
#include <dwrite_1.h>
#include <dwrite_2.h>
#pragma comment(lib,"dwrite.lib")
#pragma endregion
#pragma region D3D
#include <dxgi.h>
#include <d3d11.h>
#include <d3d11_1.h>
#include <d3d11_2.h>
#include <DirectXMath.h>
#include <DirectXColors.h>
#include <DirectXCollision.h>
#include <DirectXPackedVector.h>
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")
#ifdef _DEBUG
#include <d3dcompiler.h>
#pragma comment(lib, "d3dcompiler.lib")
#endif
#pragma endregion
#pragma region XAudio
#include <Xaudio2.h>
#include <x3daudio.h>
#pragma comment(lib, "Xaudio2.lib")
#pragma endregion
WIN32 SDK D3D + D2D + XAudio + WIC includes and static libs. Put these in your pch.h or stdafx.h after <windows.h>.
And the Desktop DirectX Graphics Reference links:
Direct3D11
Direct2D
DirectWrite
XAudio2
Of course it's possible to writing an normal Directx desktop programs with the Win8 SDK since DirectX SDK now a part of the Windows SDK, and you can build a desktop app with the Windows8 SDK just like old DirectX SDK just include your header, link your library and write your app, Just be aware that this SDK don't supports writing app to older version of DirectX (DirectX9, 10) and older it's only supports DirectX11,
If you want to writ a app to older version of DirectX then use the old one SDK
Related
I am able to use openssl in the source code below, but without the libeay32.dll file, my project does not open. I want to add it static and eliminate the need for dlls. How can I do that ?
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <openssl/bio.h>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#pragma comment(lib, "libeay32.lib")
#pragma comment(lib, "ssleay32.lib")
TForm1 *Form1;
void __fastcall TForm1::Button1Click(TObject *Sender)
{
BIO* key;
void* buf;
key=BIO_new_mem_buf(buf,100);
}
//---------------------------------------------------------------------------
I tried to compile statically but without success.
I'm building a framework that needs to work with Swift and Objective-C. It is built with Swift.
It works fine in a Swift app. #import MyFrameworkName works just as expected. But I can't seem to make it work in an Objective-C app.
#import <MyFrameworkName/MyFrameworkName-Swift.h>
This is the build log:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/MyFrameworkName.h"
^
/Users/user/Projects/MyFrameworkName/Sources/MyFrameworkName.h:20:9: error: module 'CommonCryptoBridge' not found
#import CommonCryptoBridge;
^
<unknown>:0: error: could not build Objective-C module 'MyFrameworkName'
This is my framework header:
#import <UIKit/UIKit.h>
FOUNDATION_EXPORT double MyFrameworkNameVersionNumber;
FOUNDATION_EXPORT const unsigned char MyFrameworkNameVersionString[];
#import CommonCryptoBridge;
The CommonCryptoBridge is a module to enable CommonCrypto in Swift, defined by CommonCryptoBridge.h and CommonCryptoBridge.modulemap:
CommonCryptoBridge.h
#ifndef __COMMONCRYPTO_BRIDGE__
#include <CommonCrypto/CommonCrypto.h>
#define __COMMONCRYPTO_BRIDGE__
#endif /* __COMMONCRYPTO_BRIDGE__ */
CommonCryptoBridge.modulemap
module CommonCryptoBridge [system] {
header "CommonCryptoBridge.h"
export *
}
I'm trying to run native object-c code on my Mac application.
My code looks like:
MainWindow.h:
#ifdef Q_OS_MAC
#include <Carbon/Carbon.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <mach/mach_port.h>
#include <mach/mach_interface.h>
#include <mach/mach_init.h>
#include <IOKit/pwr_mgt/IOPMLib.h>
#include <IOKit/IOMessage.h>
#endif
MainWindow.cpp:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
#ifdef Q_OS_MAC
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver: self
selector: #selector(receiveSleepNote:)
name: NSWorkspaceWillSleepNotification object: NULL];
#endif
}
#ifdef Q_OS_MAC
- (void) receiveSleepNote: (NSNotification*) note
{
NSLog(#"receiveSleepNote: %#", [note name]);
}
#endif
But am getting errors that seems that QT does not understand the code structure:
application.cpp: error: expected external declaration
- (void) receiveSleepNote: (NSNotification*) note ^
In order to compile objective-c with C++, you need to have the objective-c code in a .m or .mm file.
The accompanying header can then contain functions that can be called from C++ and the body of those functions can contain objective-c code.
So let's say, for example, we wanted to call a function to pop up an OSX notification. Start with the header: -
#ifndef __MyNotification_h_
#define __MyNotification_h_
#include <QString>
class MyNotification
{
public:
static void Display(const QString& title, const QString& text);
};
#endif
As you can see, this is a regular function in a header that can be called from C++. Here's the implementation:-
#include "mynotification.h"
#import <Foundation/NSUserNotification.h>
#import <Foundation/NSString.h>
void MyNotification::Display(const QString& title, const QString& text)
{
NSString* titleStr = [[NSString alloc] initWithUTF8String:title.toUtf8().data()];
NSString* textStr = [[NSString alloc] initWithUTF8String:text.toUtf8().data()];
NSUserNotification* userNotification = [[[NSUserNotification alloc] init] autorelease];
userNotification.title = titleStr;
userNotification.informativeText = textStr;
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];
}
The implementation contains objective-c and due to its .mm file extension, the compiler will handle this correctly.
Note that in the example you provide in the question, you need to think about what the code is doing; especially when using 'self', as I expect that would need to refer to an Objective-C class, not a C++ class.
I have created an OSX command app in Xcode 5
Here is the main.m
#import <Foundation/Foundation.h>
#import "ConnectionListener.h"
#import "SOMatrix.h"
int main(int argc, const char * argv[])
{
#autoreleasepool {
NSLog(#"Hello, World!");
print_m();
}
return 0;
}
and here is my header file:
#ifndef __GDC1__SOMatrix__
#define __GDC1__SOMatrix__
#ifdef __cplus
#include <iostream>
#endif
int print_m();
#endif /* defined(__GDC1__SOMatrix__) */
And here is a partial listing of the SOMatrix.mm file
#include "SOMatrix.h"
#include <iostream>
using namespace std;
int print_m() {
// logic removed to keep it short; no compile time error
return 0;
}
When I build the project I got a linker error:
Undefined symbols for architecture x86_64:
"_print_m", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I don't understand why the function is showhow changed to have a leading underscore in the name ('_print_m').
Why this error occurs? Do I need to add the .mm file explicitly to the project?
You need to change these lines:
#ifdef __cplus
#include <iostream>
#endif
to this in your .h file:
#ifdef __cplusplus
#include <iostream>
extern "C"
{
#endif
with a companion:
#ifdef __cplusplus
}
#endif
at the end of the .h file.
Because you are trying to access a C++ function from Objective-C, and C++ tends to do a bit of name mangling (adding the underscore, for example). Adding the "extern "C"" bit allows your Objective-C code to find your C function declarations. The answers to this related question might elaborate on things a bit better than I can.
My *-Prefix.pch file looks like the following
//
// Prefix header for all source files of the 'stuff' target in the 'stuff' project
//
#import <Availability.h>
#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
So why is it then when I remove #import from a file in Xcode 4.6.2 all the syntax highlighting turns off for all Foundation Framework objects? The code still compiles and run correctly.