Loading a COM DLL - c++

I just started using QT. Right now I need to transfer some code I have on a Visual C++ project to QT.
The only thing the project does at the moment is open photoshop and set the visible flag to false (it will be used for automation, so a lot of things will be added later).
What I do is, I import 2 photoshop dlls (NOTE: I don’t have .h or .lib for them, just the .dll files)
The method I’m using to import these dlls is through import libid, since all the other methods I tried didn’t work. They are COM objects, btw.
This is my VC++ code:
//library ID of Photoshop.dll
#import "libid:E891EE9A-D0AE-4cb4-8871-F92C0109F18E"
//library ID of PhotoshopTypeLibrary.dll
#import "libid:4B0AB3E1-80F1-11CF-86B4-444553540000"
int main()
{
Photoshop::_ApplicationPtr app( __uuidof(Photoshop::Application));
app->Visible = false;
return 0;
}
Now, QT gives me some warnings and errors on the import lines:
warning: #import is a deprecated GCC extension
error: libid:E891EE9A-D0AE-4cb4-8871-F92C0109F18E: No such file or directory
And then, after that, it says (obviously) that “Photoshop” is not declared.
Now, I searched and the closest solution I found was to include the .tlh files that were created on my VC++ project, but when I did that, I got more than 1 thousand errors and warnings, so that obviously didn’t work.
Can someone please tell me what to do here? I’m seriously stuck!

Related

Newbie help for Visual C++ project references

I know next to nothing about C++, except that I have a missing to take someone else's C++ library and wrap it for use by C#. I found a few posts about how to do it, and I'm making my way there, bit by bit. But I've hit a wall at this point.
According to this post I'm supposed to create a new managed C++ project. This I have done, and I added a reference to the project I'm supposed to be wrapping. So my code looks like this:
#include "stdafx.h"
#include "DrmWrapper.h"
#include "../OtherLibrary/drm/adept/src/adept_provider.h"
DrmWrapper::DrmWrapper(dpdrm::DRMProcessorClient * client, dpdev::Device * device)
{
adept::DRMProviderImpl * provider = new adept::DRMProviderImpl();
drm_processor_ = provider->createDRMProcessor(client, device);
}
unsigned DrmWrapper::initSignInWorkflow(unsigned workflows, const dp::String& authProvider, const dp::String& username,
const dp::String& password)
{
return drm_processor_->initSignInWorkflow(workflows, authProvider, username, password);
}
All looks good. But when I try compile my wrapper project, I get an error:
d:\src\drm-wrapper\OtherLibrary\drm\adept\src\adept_provider.h(26): fatal error C1083: Cannot open include file: 'dp_all.h': No such file or directory
Eh...whut? I'm not trying to compile the adept library. That already built fine by itself. I just want to compile my own wrapper project. And the dp_all.h file does exist, in the same folder as adept_provider.h.
Clearly there's some paradigm shift I'm not making from C# to C++; it seems like the code is being rebuilt as if the referenced project's source file were in my project folder.
What's the secret switch to get this working?
You should add ../OtherLibrary/drm/adept/src as one of the places where your project looks for header files (in C++/General/Additional Include Directories).
You should change #include "../OtherLibrary/drm/adept/src/adept_provider.h" to #include "adept_provider.h".
What's happening is that the compiler is looking for dp_all.h relative to your project not to the other project. Compilation is not totally separate in C++, headers files are shared between projects and are recompiled in each project where they are used.

Ignore a Library in an iOS app to compile for simulator

I've seen some post that already reference my problem and solve it, but it was active 2 years ago and I tried to use it but it doesn't work for me (maybe a difference in Xcode or something)
here is the related posts :
Making Xcode ignore static library when building for iOS
Simulator
Xcode: Conditional Build Settings based on architecture (Device
(ARM) vs Simulator (i386))
I have a project that work with vuforia, a c++ library, but this library isn't compatible with the simulator. I want to compile my project for the simulator (even if the part using the lib obviously won't work) to test other functionalities of my app.
In my build settings, I had this :
Header Search Paths : ../../build/include
Library Search Paths : ../../build/lib/arm
I had nothing in Other Linker Flags
Following the posts, I tried to remove the lib exclusively for simulator, and I currently have :
The compilation error changes and it is now "Vuforia/Vuforia.h file not found" in one of my view controller that use the lib.
So I took care of it, and I added the preprocessor instruction
#if !(TARGET_OS_SIMULATOR)
....
#endif
It work for many of it, but one error is still there, even if it is inside a block like showed above
#if !(TARGET_OS_SIMULATOR)
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#import <sys/time.h>
#import <Vuforia/Vuforia.h>
#import <Vuforia/State.h>
#import <Vuforia/Tool.h>
#import <Vuforia/Renderer.h>
#import <Vuforia/TrackableResult.h>
#import <Vuforia/VideoBackgroundConfig.h>
...
#endif
At the end I also tried to play with Other Linker Flags but it doesn't help...
Can you help me to find how to bind the library only for iOS device and run the app on the simulator ?
Thanks !
I'd avoid setting different header search paths.
Use TargetConditionals.h as you mentioned to disable the Vuforia when building for the simulator. Then, to take care of linking, I suggest using OTHER_LDFLAGS instead of the "Link with libraries" build phase since you cannot conditionalize that build phase by platform. You can easily do this with an xcconfig like:
OTHER_LDFLAGS = -framework Vuforia
OTHER_LDFLAGS[sdk=*simulator] =

Visual Studio 2012 Express Acting Very Strange

Writing a program, using COM ADO library. Everything is working fine, all as it should be. Then low and behold I need to use a function from the ADOX library too. So I add the necessary #import command for ADOX and the compiler generated header throws over a 100 errors.
My import statements are
#import "msado15.dll" rename("EOF", "EndOfFile")
#import "msadox.dll" no_namespace
Note that I lifted those statements straight out of MSDN example, located here https://msdn.microsoft.com/en-us/library/windows/desktop/ms676148%28v=vs.85%29.aspx
Now I discovered that if I add a using command, it sort of works.
#import "msado15.dll" rename("EOF", "EndOfFile")
#import "msadox.dll" no_namespace
using namespace ADODB;
The above will compile and my program works as it should. However, it screws up Visual Studio's contextual visualization. All the type definitions are displaying in black instead of blue and has the red squiggly error indicator underlining it. Mouse over context help says "undefined identifier" even though it will compile fine. And you cant get the type information menu or definition by right clicking on the text.
What is going on here?
Thanks

C++: Why does libtiff break the console-output?

So finally I’m not able to help myself out by researching anymore. Hopefully you can help me.
I recently decided to learn C++ in the context of my bachelor-thesis: My first aim is to read the pixel-values of a tiff-image with the libtiff-library. Yet, every call of a function of the library seems to break parts of my program.
Here’s the simple “HelloWorld”-Program, it works as it should:
#include "tiffio.h"
#include <iostream>
using namespace std;
int main() {
cout << "Hello" << endl;
// TIFF* tif = TIFFOpen("path to .tif", "r");
return 0;
}
When I uncomment the second line in main(), the code still does compile without errors (except the warning that ‘tif’ isn’t used) and I can start the program as usual. Yet nothing gets printed into the console anymore. Not “Hello” nor any errors.
Any suggestions where the error could be? The code should be alright, I guess I messed something up during the setup of the library or so. Here’s what I did:
I managed to set up eclipse (Mars, 32bit) for C++ and MinGW (32bit) on my 64bit Win7, then downloaded libtiff 4.0.4 and built it following this instruction.
I created a new C++-project with the mentioned code and did the following adjustments in the project-properties:
Project->Properties->C/C++ General->Paths and Symbols->Library
Paths-> Added “D:/… /tiff-4.0.4/libtiff/.libs”
Project->Properties->C/C++ Build->MinGW C++
Linker->Miscellaneous->Set Linkerflags to “-static-libgcc
-static-libstdc++”
Project->Properties->C/C++ Build->MinGW C++ Linker->Libraries-> Set
(-L) to “D:/… /tiff-4.0.4/libtiff/.libs” and (-l) to “libtiff”
I know the .tif is a valid file as I implemented parts of my program in C#, using the LibTiff.NET library by BitMiracle.
Thank you in advance!
Edit 1: The same error occures, even if TIFF* tif = TIFFOpen("path to .tif", "r"); is never called but written down in a dead part of the code. Debugging does not work either, the program seems to be terminated (exit value 0) before a single line is executed, without any error-reports.
I had the same issue and managed to get rid of it.
I set up eclipse (Mars) for C++ and MinGW on my 64bit Win7, then downloaded libtiff 4.0.4 and built it following this instruction.
After the build, I got two directories containing files:
include
tiff.h
tiffconf.h
tiffio.h
tiffio.hxx
tiffvers.h
lib
libtiff.a
libtiff.dll.a
libtiff.la
libtiffxx.a
libtiffxx.dll.a
libtiffxx.la
I also linked all include files and only the libtiff.a to my project and that solved it, ie, the other lines are now executed.
I hope, I helped with this post.

Having trouble embedding Lua for Windows install into C++ program

This is the first question I have found myself not being able to get to the bottom of using my normal googling/stack overflowing/youtubing routine.
I am trying to compile a minimal Lua program inside of a C++ environment just to ensure my environment is ready to development. The Lua language will be later used for User Interface programming for my C++ game.
First some basic information on my environment:
Windows 7 64-bit
Visual studio 2010
Lua for Windows 5.1 (latest build I could download from google code)
Here is the code I am trying to compile:
// UserInt.cpp : Defines the entry point for the console application.
//
#pragma comment(lib,"lua5.1.dll")
#include "stdafx.h"
#ifndef __LUA_INC_H__
#define __LUA_INC_H__
extern "C"
{
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
}
int _tmain(int argc, _TCHAR* argv[])
{
lua_State * ls = luaL_newstate();
return 0;
}
#endif // __LUA_INC_H__
Here is the Error I am getting:
1>UserInt.obj : error LNK2019: unresolved external symbol _luaL_newstate referenced in function _wmain
1>c:\users\deank\documents\visual studio 2010\Projects\UserInt\Debug\UserInt.exe : fatal error LNK1120: 1 unresolved externals
Things I have tried:
I have read about lua_open()(and several other functions) no longer being used so I tried the newstate function instead. I get the same error. This was more of a sanity check than anything. I am using 5.1 and not 5.2 so I do not think this really matters.
I have also read this thread Cannot link a minimal Lua program but it does not seem to help me because I am not running the same environment as that OP. I am on a simple windows 7 and visual studio environment.
The top pragma comment line was something I saw in yet another thread. I get the same error with or without it.
I have gone into my visual studio C++ directories area and added the lua include to the includes and the lua lib to the libraries.
So it seems like my program is seeing the .h and seeing the symbol. But for some reason it is not getting the .cpp implementation for the functions. This is why I was hoping including that .dll directly would help fix the problem, but it hasn't.
So, I feel like I have exhausted all of my options solving this on my own. I hope someone is able to help me move forward here. Lua looks like an awesome language to script in and I would like to get my environment squared away for development.
I hope it is just some silly error on my part. I believe I have provided as much information as I can. If you need more specifics I will update with info if I can provide it.
Edit1
Tried the solution in this Can't build lua a project with lua in VS2010, library issue suspected
That did not work either.
You'll need to have the library (.LIB) file and add that to VS. Use Project > Properties and go to Linker > Input and add the full .lib filename to the "Additional Dependencies" line. Note that the .LIB is different from the .DLL.
Personally, I prefer adding the source code to my project, over referencing the dynamic link library. The following procedure will let you do as such.
Download the source code ( http://www.lua.org/ftp/ ), uncompress it.
In Visual Studio, choose File > New > Project and choose Visual C++, Win32, "Win32 Console Application".
In your project in Visual Studio, add all the source code, except luac.c. Also delete the main() function out of the file that VS created for you. This is usually given the name of the project you specified with the .cpp file extension. You could just remove this file all-together from the project.
Build and Run.
This is the Lua console