This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JNI problem  RSS feed

 
shawn kennedy
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have tried using cygwin to compile my c code (for use as a native method in java)using the following command:
gcc -D__int64="long long" -mrtd -D_REENTRANT -mno-cygwin -I/cygdrive/c/j2sdk1.4.2_03/include
-I/cygdrive/c/j2sdk1.4.2_03/include/win32
-Wl,-add-stdcall-alias -shared -o CapscanSortCode.dll
CapscanSortCode.c
But it gives the following error:

cygdrive/c/DOCUME~1/Madhu.Roy/LOCALS~1/Temp/cca4NCIz.o(.text+0x93c):CapscanSort
> Code.c: undefined reference to `_SCD_SetPath'
>
/cygdrive/c/DOCUME~1/Madhu.Roy/LOCALS~1/Temp/cca4NCIz.o(.text+0xc21):CapscanSort
> Code.c: undefined reference to
> `_SCD_BuildMSortCodesList'
>
/cygdrive/c/DOCUME~1/Madhu.Roy/LOCALS~1/Temp/cca4NCIz.o(.text+0xc47):CapscanSort
> Code.c: undefined reference to `_SCD_Presortation'
> collect2: ld returned 1 exit status
THe functions on which it gives errors have been defined in a file called scd_api.h and this has been included in the .c file as #include "scd_api.h"
But it gives me the error yet.
Please can someone help me.
 
Jayesh Lalwani
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the scd_api.h located? I think you will have to include the path to scd_api.h in the include path



I have never used cygwin. Is scd_api.h part of the compiler? If it is then you might want to change our include to

[ April 13, 2005: Message edited by: Jayesh Lalwani ]
 
shawn kennedy
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well scd_api.h is not a part of the compiler thats the reason why i needed to user the include "scd_api.h".
 
Jayesh Lalwani
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you should put the path to scd_api.h in your include paths

BTW, even if scd_api.h is part of compiler you have to include it in you C file. You don't have to add it in your Include paths when you build your app. To draw in analogy with Java, #include in C is similar to import in Java. So, just like if you are using java.io, you say import java.io.* in your java file, you have to #include in your C file. Just like you don't have to specify java jar files in your classpath when you build and run your app, you don't have to specify the include path when you build your C app

If scd_api.h is not part of the compiler, you have to include it in your C file, and also add it into your Include paths when you build your app.. To draw an analogy with Java again. In java, if you are using a third party library, you will inport the package in your java, as well as specify the third party jar in your clsspath. Similarily, in C if you are using third party API, you have to include the .h in your .C file, and specify the include path when you build the app.

You always need #include "scd_api.h" or #include <scd_api.h> no matter what. Sometimes, many compilers provide utility includes that include all the commonly used api, but that's no guarantee that all API's will get included
 
shawn kennedy
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What i meant was since its not a part of the compiler i used #include "scd_api.h" instead of #include <stdio.h>.
Anyhow thats not what the problem is because the include statements exists in my c file and the scd_api.h is in the appropriate path.The problem is i cant get the .c file to compile to generate a .dll without those errors i stated previously and cant seem to understand why it wont work
 
Jayesh Lalwani
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to put scd_api.h in your include path when you compile your C file. See my first post. I am pasting it again here



The compiler won't know where the header file is unless you tell it where it is.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!