compiling com.mysql.jdbc.Driver with gcj
Radu Racaru
radu.racaru@gmail.com
Mon Oct 10 17:11:00 GMT 2005
Hi,
you need to link to the driver also, that's why the compiler says
"undefined reference to".
Like:
gcj-4.0 --classpath=../mysql-connector-java-3.1.10-bin.jar:.
org/dcwatch/dchub/core/*.java
org/dcwatch/dchub/util/*java org/dcwatch/sql/SqlConnection.java
ForceInclude.java
--main=org.dcwatch.dchub.core.Core
mysql-connector-java-3.1.10-bin.jar -o faszom2.out
note that I've added the jar to the compile line, putting it in
classpath is not enough.
As an alternative you can have the driver compiled to an object file:
gcj-4.0 -c mysql-connector-java-3.1.10-bin.jar -o
mysql-connector-java-3.1.10-bin.o
then only link with it:
gcj-4.0 --classpath=../mysql-connector-java-3.1.10-bin.jar:.
org/dcwatch/dchub/core/*.java
org/dcwatch/dchub/util/*java org/dcwatch/sql/SqlConnection.java
ForceInclude.java
--main=org.dcwatch.dchub.core.Core mysql-connector-java-3.1.10-bin.o
-o faszom2.out
On 10/9/05, Khiraly <khiraly123@gmx.net> wrote:
> Hi!
>> I wanted to compile my application to native code.
> My application use mysql, so I need mysql driver to compile into the
> binaries.
>> I have tried the following method:
> 1. Create a class with include mysql driver into the native code:
> public class ForceInclude {
> private static final Class class1 = com.mysql.jdbc.Driver.class;
> ForceInclude() {
> }
> }
>> Now the compile command:
> gcj-4.0 --classpath=../mysql-connector-java-3.1.10-bin.jar:. org/dcwatch/dchub/core/*.java
> org/dcwatch/dchub/util/*java org/dcwatch/sql/SqlConnection.java ForceInclude.java
> --main=org.dcwatch.dchub.core.Core -o faszom2.out
>> The result is this:
> /tmp/ccINcMTs.o: In function `ForceInclude::__U3c_clinit__U3e_()':
> ccqmLQg5jx:(.text+0xfc00): undefined reference to `com::mysql::jdbc::Driver::class$'
> ccqmLQg5jx:(.text+0xfc12): undefined reference to `com::mysql::jdbc::Driver::class$'
> collect2: ld returned 1 exit status
>>> I have found this method on the following link:
> http://www.cs.umanitoba.ca/~eclipse/6-Compiling.pdf
>> There are others with the same problem (no result):
> http://66.249.93.104/search?q=cache:-QJ78MPiHzoJ:dbforums.com/t576436.html+gcj+com::mysql::jdbc::Driver::class%24&hl=hu&lr=lang_en|lang_hu&client=firefox
>>> How can I include mysql driver into my native code?
>> Best regards,
> Khiraly
>>
More information about the Java
mailing list