I have written a program that creates chess diagrams using post script. I want to convert the resulting *.eps file to an equivalent *.jpg file using ghost script. I have succeeded in doing this in a C# project but I cannot get it to work in C++ or C++/CLI, either one. The problem is in getting access to the gsdll32.dll methods.
In C# I use this code:
[DllImport ("gsdll32.dll", EntryPoint = "gsapi_new_instance")]
private static extern int CreateAPIInstance (out IntPtr instance, IntPtr caller);
My attempts to use DllImport in C++ have failed.
In a C++/CLI project I get the following error when trying to add a reference:
Could not add a reference to 'S:\ScruffySoft\UseGhostScript\bin\Debug\gsdll32.dll' as it is not of a type or version current project can use.
In a C++ project I added the gsdll32.dll as a 'Solution item' and when building get the error message:
Error LNK1107 invalid or corrupt file: cannot read at 0x2B8 UseGhostScriptConsole S:\ScruffySoft\UseGhostScriptConsole\gsdll32.dll
So the question is: how do I get access to the ghost script DLL?
Thanks,
Dick
Related
I have a simulink working simulink schema in which there are some s-function, I want to export this code in c++ and compile it. I already tried to export and compile a simple schema and it works, but when i try to compile the exported code of my project I get a lot of errors like
error: #error Unrecognized use
error: #error Must define one of RT,nNRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE
error: #error Unhandled case
error: ‘mxArray’ does not name a type mxArray **dlgParams; /* The S-function parameters
error: ‘mxArray’ has not been declared mxArray **)
error: ‘mxArray’ does not name a type mxArray *propVal;
error: ‘RTWSfcnInfo’ does not name a type; did you mean ‘RTWLogInfo’? RTWSfcnInfo sfcnInfo
The main settings that i used are:
Code generation system target file --> grt.tlc
language --> C++
Pack code and artifact --> <name_zip>
Tool chain GNU gcc/g++ | gmake (64-bit Linux)
default parameter behavior --> tuanble
code interface packaging --> nonreusable function
external mode --> chcked
standar math library --> c++ 03(ISO)
single output/update function --> checked
i used a fixed step size solver
Im using Ubuntu 18.
The source is generated succesfully the problem is when i try to compile the code.
Once the code is generate I get a zip folder with all the sources and also some external header file that I include when I make the CMakeLists.txt. I also tryied to compile directly the code with the .mk file but also I get a bounch of errors. The problem is realated with the s-function because I built a simple simulink schema with a source an s-function that implements a dynamical model and an output and when i generate the code and compile it I get the same errors. I also tryied to make a simple schema without s-function and this works. So is there any settings for the s-function to be exportable
At the end I found an answer that I post here in case someone else has my same problem.
The solution that worked form my is:
First of all once you have the generated zip file with all the sources and headers open it and load on the Matlab workspace the file buldinfo.mat then in the Matlab shell run
packNGo(buildInfo)
in this way you generate a new .zip with all the sources and headers, this .zip differs from the previous because is flat, no nested folder.
Inside this folder there is a file called define.txt with a list of variables, all these variables should be passed as flags to the compiler. For example in my case I use a CMakelists.txt so to set these flags I used
set(CMAKE_CXX_FLAGS "-Wall -Wextra -DMODEL=test_sum_gain -DNUMST=2 -DNCSTATES=2 -DRT -DUSE_RTMODEL -DON_TARGET_WAIT_FOR_START=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=1 -DEXT_MODE=1 -DMAT_FILE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0")
this depends on the way in which you compile the source, but in any case you should set these variables that is I am not wrong are just a directive for the precompiler.
These two things worked for me.
I am trying to move an application that uses C++Builder's TAmazonConnectionInfo to access objects on Amazon Simple Storage Service (S3). I had a version working in C++Builder 10.1 Berlin, but when I try to move it to 10.3 Rio, the link fails with an Unresolved external error:
[ilink32 Error] Error: Unresolved external '__fastcall Data::Cloud::Amazonapi::TAmazonStorageService::GetObjectW(System::UnicodeString, System::UnicodeString, System::Classes::TStream *, Data::Cloud::Cloudapi::TCloudResponseInfo *, Data::Cloud::Amazonapi::TAmazonRegion)'
The simplest reproduction of this error is:
Create a new C++ Builder VCL Application
Place a TAmazonConnectionInfo object and a button on the form and double-click the button
Replace the click handler with:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TCloudResponseInfo * ResponseInfo = NULL;
TAmazonStorageService *StorageService = NULL;
TStream* stream;
String ObjectName;
StorageService->GetObject(ObjectName, ObjectName, stream, ResponseInfo);
}
(I realize that this routine won't work because nothing is initialized, but this will produce the link error with the least amount of code).
I looked for a code sample showing how this should work, but I cannot locate the code samples for RAD Studio 10.3 Rio on my system, and it does not appear that the samples have been updated for Rio on the RAD Studio Demo Code on SourceForge.
I did find the samples on Github at https://github.com/Embarcadero/RADStudio10.3Demos/tree/master/CPP, but the Cloud samples do not appear to have been migrated for C++ Builder, only for Object Pascal.
I tried adding CloudService.lib to the project, but that did not help. Neither did adding:
#pragma link "Data.Cloud.CloudAPI"
#pragma link "Data.Cloud.AmazonAPI"
So, is there a working C++Builder sample that compiles and links under 10.3 Rio? How can I get this project to compile and link?
The problem is that the Data.Cloud.AmazonAPI.hpp header includes internally the wingdi.h Windows API header. This header has a macro that replaces GetObject for GetObjectA/W.
The workaround I managed to get working was to add the following to the Data.Cloud.AmazonAPI.hpp header, just below where the #includes end (around line 27):
#pragma push_macro("GetObject")
#undef GetObject
Then, at the end of the header, just before the #pragma delphiheader end. (around line 897) add the following:
#pragma pop_macro("GetObject")
This solves the headers issue, but you still have to add this around the code where you want to use that function so it compiles, otherwise it is going to try to compile GetObjectW that now doesn't exists at compile time.
I had the same problem.
I just tested this solution, it works!
Thank you!
You must copy the file to the desktop in order to be able to modify it, then recopy it in the installation directory.
I add that it is necessary to initialize the property "Storage EndPoint" of the TAmazonConnectInfo component with the name of the EndPoint that you must create from your Bucket
I'm fairly new to Xcode and have recently gotten an error message that is probably clear to anyone who knows what they're doing, but I am unsure how to react to this one.
I have a project that is mostly C++, with just a few C files in it. Everything was fine until I tried to add some code to find the computer's MAC address. Apple provides a project example (GetPrimaryMACAddress), and I downloaded, built, and tested that. It works just fine.
After that, I simply copied the C source from the Apple example project and included it into my code project. Then I started getting this error message:
I have tried including the IOKit framework explicitly via the linker; no help. I tried adding more #include statement to the Apple example code; no help. I think that I do not understand what the compiler message is telling me regarding importing from module 'Darwin.MacTypes'.
Clicking on the error message took me to a line in usr/include/MacTypes.h:
I'm not clear on how to Import Darwin.MacTypes. I don't really understand how the source code for GetMACAddress could compile so effortlessly in one project and not another. I didn't rearrange nor add nor delete any of the #include statements in the Apple-supplied C file.
I'll bet there is a simple answer that I am just not seeing. How should I react to this error message?
I had a similar problem with types like UInt16 and UInt32. I just included the MacTypes with the following include statement:
#include <MacTypes.h>
This solved all my type-problems for my example c-file.
Let me guess, when you want to compile C++ source, you should create a C++ source file
(On the toolbar: File > New > File.. > Source > C++ File)
I built Qt from source (dlls) and am trying to build an application that uses the Qt dlls. I don't have a lot of experience with C++ so I'm running into what I'm sure is a very basic issue.
My builds are failing on the includes with errors like so:
Fatal error: QNetworkProxy: No such file or directory
Here is the g++ command I am using (I also used -L to add the correct folder to the lib path, but that also didn't work):
g++ -l..\..\wkqt\bin\QtCore4.dll -l..\..\wkqt\bin\QtNetwork4.dll -l..\..\wkqt\bin\QtWebKit4.dll -I..\include -Ishared -Ipdf -Ilib -Iimage -o ..\bin\wkhtmltopdf.exe pdf\*.cc lib\*.cc image\*.cc shared\*.cc
I tried in Visual Studio as well (assuming it wouldn't build, but I wanted to see if I could at least include the Qt dlls from there properly) and I am getting the same errors. Am I doing something wrong with the way I am compiling with g++? If I am linking with the Dlls properly then what is the proper way to use Qt functions from my code?
To clarify, I am not looking for how to properly use Qt. My question is: what is the proper way to use functions defined in any Dll from native C++ code? I apologize if this is a very basic question, but I'm unable to find a clear answer on Google and I don't have any experience with C++ and including third party libraries for use from C++ code.
DLLs can be used by dynamicly loading them and calling their used functions.
to call the exposed functions first define their syntax in the begining
suppose function is syntax is
BOOL MyFunction(int a,char* pszString)
then define syntax
#typedef BOOL (WINAPI *PMYFUNCTION)(int a,char* pszString)
then make object
PMYFUNCTION pfnMyFunction;
and get valid pointer by calling GetProcaddress after loadlibrarycall
HMODULE hlib= Loadlibrary("c:\\Mylib.dll");
if(hlib)
{ pfnMyFunction = (PMYFUNCTION)Getprocaddress(hlib,"MyFunction"); }
Hope this helps...
I have created a COM callable DLL in C# .NET 2.0 and created a TLB
from the assembly using the .NET regasm tool.
In Borland C++ Builder 4.0 I go to Project->Import Type Library-> and
find my DLL's type library there and click "Ok" to import it.
BCB creates an HardwareCheck_TLB.cpp & HardwareCheck_TLB.h file.
In a cpp file of the project I want to use the DLL I put:
#include "HardwareCheck_TLB.h"
at the top.
Then in code if I try to declare an object of that type in code:
IHardwareCheck hc = new IHardwareCheck();
I get the following compiler error:
[C++ Error] Unit1.cpp(22): E2352 Cannot create instance of abstract
class 'IHardwareCheck'.
[C++ Error] Unit1.cpp(22): E2353 Class 'IHardwareCheck' is abstract
because of '__stdcall IHardwareCheck::IsExpress(wchar_t * *,TOLEBOOL
*) = 0'.
Anybody have any ideas how to get rid of this error?
Thanks!
COM clasess cannot be created using new. You need to use the CoCreateInstance system call (see MSDN) or some wrapper provided by Borland (such as the one mentioned by zer0_ring).
It should generate some TCoClassCreatorT<> types that you can do a
CoHardwareCheck::Create(&hc)
You may have to look at the tlibimp.exe that Borland distributes with its products. I've gone through this before with that program but never was able to get the Co classes generated, maybe you'll have better luck.