I am new to Dev C++ but not new to programming. I am trying to write a program for work that will interface my as/400 system, I already have a similar program in Visual Basic for Applications in Excel but I want to use C++ because it is faster and a stand-alone environment, among other things.
The documentation for the as/400 emulator says: The linker must be instructed to include the ECL linkable library file (PCSECLVA.LIB). This is done by specifying the fully qualified name of the library file on the linker command line.
I am doing that, as you can see below in the output, and I keep getting undefined reference errors.
I have tried in both Dev C++ portable (4.9.9.2) and wxDev C++ 7.0.0.92 and get the same error from both. The two-line code fragment for initializing the system I took directly from the sample documentation.
include <cstdlib>
include <iostream>
include "eclall.hpp"
using namespace std;
int main(int argc, char argv[])
{
ECLPS PSObject;
PSObject = new ECLPS('A');
system("PAUSE");
return EXIT_SUCCESS;
}
The header compiles fine (I had to make a slight modification for it to recognize the compiler), and if I comment out the PSObject = new ECLPS('A'); it compiles just fine... but if I don't, I get:
C:\DOCUME~1\seniorda\LOCALS~1\Temp/ccy2baaa.o(.text+0x185):as400test.cpp: undefined reference to `ECLPS::ECLPS(char)'
Here is the full text, and you can see I am linking the library file:
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\cppcode\as400test.cpp" -o "C:\cppcode\as400test.exe" -I"C:\Dev-CppPortable\App\devcpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-CppPortable\App\devcpp\include\c++\3.4.2\backward" -I"C:\Dev-CppPortable\App\devcpp\include\c++\3.4.2\mingw32" -I"C:\Dev-CppPortable\App\devcpp\include\c++\3.4.2" -I"C:\Dev-CppPortable\App\devcpp\include" -I"C:\cppcode\AS400LIBS" -L"C:\Dev-CppPortable\App\devcpp\lib" -L"C:\cppcode\AS400LIBS" -L "C:\cppcode\AS400LIBS\pcseclva.lib" -L "C:\cppcode\AS400LIBS\pcseclvc.lib"
C:\DOCUME~1\seniorda\LOCALS~1\Temp/ccy2baaa.o(.text+0x185):as400test.cpp: undefined reference to `ECLPS::ECLPS(char)'
collect2: ld returned 1 exit status
Execution terminated
There is also a DLL version of the library file if I want to go that route... I can't get that to work either.
Is there a problem with the way I am linking, or is the library file simply incompatible? (The documentation says it is designed for IBM Visual Age C++ or Microsoft Visual C++ and gives specific instructions for compiling in those languages, but also says it should work on most other C++ compilers as well.) I have been researching for the past week and have overcome a number of things but this is the last hurdle.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Static libraries built by other tools cannot be linked using the MinGW linker.
Even if the object file format were the same, or you weer using a DLL, C++
libraries are not generally portable between compilers because different
compilers use different 'name-mangling' schemes.
You need a library specifically built to work with MinGW, or a toolchain
compatible with your library. By convention GNU libraries have a lib prefix
and a .a extension, since yours doesn't it is most probably not a GNU library
let alone a MinGW library.
The chances are that it is a MS VC++ library, and will probably work with
VC++2008 Express, which is free and frankly, better.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I kinda thought as much, especially with how the documentation touched lightly
on "it should be able to work on other compilers" but then focused
mostly on VC++ and the change in the header I had to make in order for the
headers to compile is that I had to add checking for the GCC compiler to set
the way it deals with DLLs, I guess when you have to change a header file to
work with a compiler that is a good sign the library might not work either.
I was curious how it matches the header to the library, being as the headers
never directly reference the library. So that makes sense.
At least I was doing it correctly. Thank you, I guess I will have to try
Microsoft, I was kinda hoping I could do without it. Now to see if I can still
distribute my program once it is done, under Microsoft's licensing rules...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> Now to see if I can still distribute
> my program once it is done, under
> Microsoft's licensing rules...
That is likely to be the least of your problems. There are no particular
restrictions on deployment of applications built with Microsoft's free tools,
you can use it for commercial use if you choose. I fact I would suggest that
it is far less fraught that GPL licensed tools. What may be more restrictive
perhaps is the licensing for the library you are using.
From a deployment point of view, the biggest problem with VC++ Express is that
it does not come with the deployment wizard to create an installation package.
If you write Win32 native code, you will have to install the MS VC++ x86
Redistributable package on all machines that you deploy to (this is a once
only process) get it .
If using .NET managed code, you will need to install the .NET framework on teh
target machines (although many may will have that installed in any case).
I may try MSVC if I have to... but first I was looking online and I see there
is a file REIMP that comes with MinGW that is supposed to change .LIB files to
.A, but everywhere I try looking for it is just dead links. I installed the
full version of MinGW, it does not have that file in it as I was told it
should. Does anybody know where I could get a copy of REIMP? I would like to
try that route before I abandon Dev-C++.
And everyone who would be getting this app would already be licensed to use
the as/400 system and would already be registered to use the associated
library files as well, so that wouldn't be an issue in this case. I would not
be selling it, as I am developing it at work and therefore it is property of
the company, even though it is something I am doing on my own. (Our code of
ethics says if it is done on company time with company equipment it is company
property.)
Too bad, it's going to be a nice utility.
-Dan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I managed to get REIMP and it doesn't like the library files either or the
DLLs I have, so I guess it's futile to try to make the library files work with
this compiler. I will step back and think about this... because as far as I
see, I have two options:
Try the Active-X manipulation methods instead of direct COM... that is the alternate way to manipulate this as/400 system from an outside source, or
Use a different compiler and deal with having to make people install other libraries and such to be able to use the program.
I will get this made. Thanks for your help, I would have been stuck another
two weeks trying to get past this. :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
reimp is applied only to the DLL export libraries (i.e. the .LIB file you
statically link in order to use a DLL). You do not use it on the DLL, and
cannot use it on a normal static library.
However even if it works, it will not fix the problem of different name
mangling schemes, so the symbols generated by MinGW from the header will not
match those in the export library or the DLL. This is the problem with C++
code in DLL's. It is only practical to use DLL's with C interfaces between
different compilers.
With respect to installing other libraries, it is not hard to write a script
or simple installer to do that in one click.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am new to Dev C++ but not new to programming. I am trying to write a program for work that will interface my as/400 system, I already have a similar program in Visual Basic for Applications in Excel but I want to use C++ because it is faster and a stand-alone environment, among other things.
The documentation for the as/400 emulator says: The linker must be instructed to include the ECL linkable library file (PCSECLVA.LIB). This is done by specifying the fully qualified name of the library file on the linker command line.
I am doing that, as you can see below in the output, and I keep getting undefined reference errors.
I have tried in both Dev C++ portable (4.9.9.2) and wxDev C++ 7.0.0.92 and get the same error from both. The two-line code fragment for initializing the system I took directly from the sample documentation.
include <cstdlib>
include <iostream>
include "eclall.hpp"
using namespace std;
int main(int argc, char argv[])
{
ECLPS PSObject;
PSObject = new ECLPS('A');
}
The header compiles fine (I had to make a slight modification for it to recognize the compiler), and if I comment out the PSObject = new ECLPS('A'); it compiles just fine... but if I don't, I get:
C:\DOCUME~1\seniorda\LOCALS~1\Temp/ccy2baaa.o(.text+0x185):as400test.cpp: undefined reference to `ECLPS::ECLPS(char)'
Here is the full text, and you can see I am linking the library file:
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\cppcode\as400test.cpp" -o "C:\cppcode\as400test.exe" -I"C:\Dev-CppPortable\App\devcpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-CppPortable\App\devcpp\include\c++\3.4.2\backward" -I"C:\Dev-CppPortable\App\devcpp\include\c++\3.4.2\mingw32" -I"C:\Dev-CppPortable\App\devcpp\include\c++\3.4.2" -I"C:\Dev-CppPortable\App\devcpp\include" -I"C:\cppcode\AS400LIBS" -L"C:\Dev-CppPortable\App\devcpp\lib" -L"C:\cppcode\AS400LIBS" -L "C:\cppcode\AS400LIBS\pcseclva.lib" -L "C:\cppcode\AS400LIBS\pcseclvc.lib"
C:\DOCUME~1\seniorda\LOCALS~1\Temp/ccy2baaa.o(.text+0x185):as400test.cpp: undefined reference to `ECLPS::ECLPS(char)'
collect2: ld returned 1 exit status
Execution terminated
There is also a DLL version of the library file if I want to go that route... I can't get that to work either.
Is there a problem with the way I am linking, or is the library file simply incompatible? (The documentation says it is designed for IBM Visual Age C++ or Microsoft Visual C++ and gives specific instructions for compiling in those languages, but also says it should work on most other C++ compilers as well.) I have been researching for the past week and have overcome a number of things but this is the last hurdle.
forgot to mention this is on Windows XP, if that makes a difference.
Static libraries built by other tools cannot be linked using the MinGW linker.
Even if the object file format were the same, or you weer using a DLL, C++
libraries are not generally portable between compilers because different
compilers use different 'name-mangling' schemes.
You need a library specifically built to work with MinGW, or a toolchain
compatible with your library. By convention GNU libraries have a lib prefix
and a .a extension, since yours doesn't it is most probably not a GNU library
let alone a MinGW library.
The chances are that it is a MS VC++ library, and will probably work with
VC++2008 Express, which is free and frankly, better.
I kinda thought as much, especially with how the documentation touched lightly
on "it should be able to work on other compilers" but then focused
mostly on VC++ and the change in the header I had to make in order for the
headers to compile is that I had to add checking for the GCC compiler to set
the way it deals with DLLs, I guess when you have to change a header file to
work with a compiler that is a good sign the library might not work either.
I was curious how it matches the header to the library, being as the headers
never directly reference the library. So that makes sense.
At least I was doing it correctly. Thank you, I guess I will have to try
Microsoft, I was kinda hoping I could do without it. Now to see if I can still
distribute my program once it is done, under Microsoft's licensing rules...
> Now to see if I can still distribute
> my program once it is done, under
> Microsoft's licensing rules...
That is likely to be the least of your problems. There are no particular
restrictions on deployment of applications built with Microsoft's free tools,
you can use it for commercial use if you choose. I fact I would suggest that
it is far less fraught that GPL licensed tools. What may be more restrictive
perhaps is the licensing for the library you are using.
From a deployment point of view, the biggest problem with VC++ Express is that
it does not come with the deployment wizard to create an installation package.
If you write Win32 native code, you will have to install the MS VC++ x86
Redistributable package on all machines that you deploy to (this is a once
only process) get it .
http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7
-A40D-3802B2AF5FC2&displaylang=en
I may try MSVC if I have to... but first I was looking online and I see there
is a file REIMP that comes with MinGW that is supposed to change .LIB files to
.A, but everywhere I try looking for it is just dead links. I installed the
full version of MinGW, it does not have that file in it as I was told it
should. Does anybody know where I could get a copy of REIMP? I would like to
try that route before I abandon Dev-C++.
And everyone who would be getting this app would already be licensed to use
the as/400 system and would already be registered to use the associated
library files as well, so that wouldn't be an issue in this case. I would not
be selling it, as I am developing it at work and therefore it is property of
the company, even though it is something I am doing on my own. (Our code of
ethics says if it is done on company time with company equipment it is company
property.)
Too bad, it's going to be a nice utility.
-Dan
I managed to get REIMP and it doesn't like the library files either or the
DLLs I have, so I guess it's futile to try to make the library files work with
this compiler. I will step back and think about this... because as far as I
see, I have two options:
Try the Active-X manipulation methods instead of direct COM... that is the alternate way to manipulate this as/400 system from an outside source, or
Use a different compiler and deal with having to make people install other libraries and such to be able to use the program.
I will get this made. Thanks for your help, I would have been stuck another
two weeks trying to get past this. :)
reimp is applied only to the DLL export libraries (i.e. the .LIB file you
statically link in order to use a DLL). You do not use it on the DLL, and
cannot use it on a normal static library.
However even if it works, it will not fix the problem of different name
mangling schemes, so the symbols generated by MinGW from the header will not
match those in the export library or the DLL. This is the problem with C++
code in DLL's. It is only practical to use DLL's with C interfaces between
different compilers.
With respect to installing other libraries, it is not hard to write a script
or simple installer to do that in one click.
Clifford