Code::Blocks is hailed as a great IDE (first link). Of course, Visual Studio isn't bad either.
But I'd try both and stick to the one I like most.
Elysia/Codeplug:
Thanks for your quick answers .... I'm already downloading these IDEs ...
After that I'll retry and let you know how did all go ...
Many thanks and BRs,
Lucas
Hi ...
I've downloaded both code::blocks and wxDec-C++ but compilation failed with both of them ...
Same error as before ...
- Output Codeblocks:
- Output xwDev-C++:-------------- Clean: default in IP_FNC ---------------
Cleaned "IP_FNC - default"
-------------- Build: default in IP_FNC ---------------
Compiling: ipfnc.cpp
Linking dynamic library: ipfnc.dll
.objs\ipfnc.o:ipfnc.cpp.text+0x99): undefined reference to `SysAllocStringByteLen@8'
collect2: ld returned 1 exit status
Creating library file: libipfnc.dll.a
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 0 warnings
Am I missing any include header? What can be wrong then? I've read here (http://forum.imasters.com.br/index.p...retorna-texto/) that the 'oleauto.h' header must be included, and it's included, however it seams that there's something still missing somewhere ...Compiler: Default GCC compiler
Building Makefile: "d:\datos\doc\tech\c++\excel\ipfnc\Makefile.wi n"
Executing make clean
rm -f "Default Profile/ipfnc.o" "Default Profile/ipfnc.dll"
g++.exe -c ipfnc.cpp -o "Default Profile/ipfnc.o" -I"C:/Archivos de programa/Dev-Cpp/lib/gcc/mingw32/3.4.5/include" -I"C:/Archivos de programa/Dev-Cpp/include/c++/3.4.5/backward" -I"C:/Archivos de programa/Dev-Cpp/include/c++/3.4.5/mingw32" -I"C:/Archivos de programa/Dev-Cpp/include/c++/3.4.5" -I"C:/Archivos de programa/Dev-Cpp/include" -I"C:/Archivos de programa/Dev-Cpp/" -I"C:/Archivos de programa/Dev-Cpp/include/3rdparty/wx/plotctrl" -I"C:/Archivos de programa/Dev-Cpp/include/3rdparty/wx/sheet" -I"C:/Archivos de programa/Dev-Cpp/include/3rdparty/wx/treemultictrl" -I"C:/Archivos de programa/Dev-Cpp/include/3rdparty/wx/things" -I"C:/Archivos de programa/Dev-Cpp/include/3rdparty/wx" -I"C:/Archivos de programa/Dev-Cpp/include/3rdparty" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/msw" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/generic" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/fl" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/gizmos" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/html" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/mmedia" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/net" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/ogl" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/plot" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/protocol" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/stc" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/svg" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/xml" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx/xrc" -I"C:/Archivos de programa/Dev-Cpp/include/common/wx" -I"C:/Archivos de programa/Dev-Cpp/include/common" -DBUILDING_DLL=1 -g3
g++.exe -shared "Default Profile/ipfnc.o" -L"C:/Archivos de programa/Dev-Cpp/Lib" -g3 -Wl,--out-implib,"Default Profile/libipfnc.a" -o "Default Profile/ipfnc.dll"
Creating library file: Default Profile/libipfnc.a
Default Profile/ipfnc.o: In function `string_ex':
d:/datos/doc/tech/c++/excel/ipfnc/ipfnc.cpp:48: undefined reference to `SysAllocStringByteLen@8'
collect2: ld returned 1 exit status
mingw32-make.exe: *** [Default] Error 1
Execution terminated
Compilation Failed. Make returned 2
Thanks in advance,
Lucas
The library is oleaut32.lib if I'm reading MSDN correctly (it was on a Windows CE page, but), so you need to link that library with your code.
You need to link against "liboleaut32.a", or "-loleaut32".
gg
In Code::Blocks you'd add 'oleaut32' (without quotes) to Project (menu)->Build Options->Linker Settings->Add
...where did all those posts come from, they weren't here when I started writing
Thanks, I got to link the code with the library ... and it compiles now ...
However, when calling the DLL from within VBA, Excel returns #VALUE! ... there is still something wrong with the types, either in the input parameters or in the return...
As far as I've read, SysAllocStringByteLen returns a BSTR ANSI string ... If I'm not wrong, it should be UNICODE (2bytes per char, ain't it), since VBA sends out an UNICODE string. (SysAllocStringByteLen)
I'll take a pause on this ...
Many Thanks ...
Lucas
Hi,
After downloading Code::blocks and wxDev-C++, I can no longer use successfully the DLL in Excel, even with a simple function.
I had this simple function ...
VBA:
DLL:Code:Declare Function square Lib "d:/datos/doc/tech/c++/excel/ipfnc/ipfnc.dll" (ByVal x As Double) As Double
... which I would use to confirm correct communication between the DLL and Excel, but now, after compiling the code, this does no longer work ... :-(Code:extern "C" __declspec( dllexport ) __stdcall double square(double x) { return 2*x; }
Could Code::blocks or wxDev-C++ be doing something different with respect to Dev-C++ 4.9.9.2? Before I could get this simple function to work ... :-S
>> it should be UNICODE ... since VBA sends out an UNICODE string
Nope. Go back and read the link in post #5, and then again with quotes in post #11.
>> I can no longer use successfully the DLL in Excel
You may of corrupted your MinGW installation by having 3 different versions installed at the same time - where one of them is in C:\MinGW - or more than one of them installed on top of each other. Or it may just be that you're not using correct build options.
You could try uninstalling all 3 and reinstall just one.
Or give Visual Studio Express a try: https://www.microsoft.com/express/Do...010-Visual-CPP
gg
Last edited by Codeplug; 12-15-2010 at 10:08 AM.
Ok, I'm trying to do the simplest code ...>> it should be UNICODE ... since VBA sends out an UNICODE string
Nope. Go back and read the link in post #5, and then again with quotes in post #11.
>> I can no longer use successfully the DLL in Excel
You may of corrupted your MinGW installation by having 3 different versions installed at the same time - where one of them is in C:\MinGW - or more than one of them installed on top of each other. Or it may just be that you're not using correct build options.
VBA:
C++:Code:Public Declare Function mult Lib _ "d:\datos\doc\tech\c++\excel\ipfnc_dll\ipfnc.dll" _ (ByVal x As Integer) As Integer
But not even with this one I'm being able to get it to work ... when I do '=mult(A3)' (where A3=2, expecting a 4) from Excel i get #VALUE!.Code:extern "C" __declspec( dllexport ) __stdcall short mult(short x); short mult(short x) { return 2*x; }
The compilation shows no error.
Am I missing something? I'm using Codeblocks 10.05 standard installation obtained from codeblocks-10.05mingw-setup.exe. Console applications do compile well and execute as expected...-------------- Clean: default in IP_FNC ---------------
Cleaned "IP_FNC - default"
-------------- Build: default in IP_FNC ---------------
Compiling: ipfnc.cpp
Linking dynamic library: ipfnc.dll
Creating library file: libipfnc.dll.a
Output size is 133.87 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
Sorry for being this annoying with this simple case ... :-S
Thnx,
Lucas
What is the full command line for the compile/link?
gg
You may need "--add-stdcall-alias" added to your linker flags.
Or "-Wl,--add-stdcall-alias" to your compiler flags.
gg
Yeap ... "-Wl,--add-stdcall-alias" did the trick ... now I can call the simple function from Excel and I got a result ...
Now I'm going back to the old BSTR problem ...
Thanks!
Lucas
pd: BTW, if possible, could you provide a link showing some info on "-Wl,--add-stdcall-alias": I really do not know what are they for ... :-P
Options - Untitled
EDIT: Okay the "let the forum use the page title as the name of the link" tactic didn't work so well there. That's a link to the ld manual. (Anything after -Wl is an option that gets passed to the linker straight.)