• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 07:35
CEST 13:35
KST 20:35
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL20] Ro24 Preview Pt2: Take-Off7[ASL20] Ro24 Preview Pt1: Runway132v2 & SC: Evo Complete: Weekend Double Feature4Team Liquid Map Contest #21 - Presented by Monster Energy9uThermal's 2v2 Tour: $15,000 Main Event18
Community News
Weekly Cups (Aug 18-24): herO dethrones MaxPax6Maestros of The Game—$20k event w/ live finals in Paris30Weekly Cups (Aug 11-17): MaxPax triples again!13Weekly Cups (Aug 4-10): MaxPax wins a triple6SC2's Safe House 2 - October 18 & 195
StarCraft 2
General
Geoff 'iNcontroL' Robinson has passed away A Eulogy for the Six Pool Weekly Cups (Aug 18-24): herO dethrones MaxPax 2v2 & SC: Evo Complete: Weekend Double Feature The GOAT ranking of GOAT rankings
Tourneys
WardiTV Mondays Maestros of The Game—$20k event w/ live finals in Paris RSL: Revival, a new crowdfunded tournament series Sparkling Tuna Cup - Weekly Open Tournament Monday Nights Weeklies
Strategy
Custom Maps
External Content
Mutation # 488 What Goes Around Mutation # 487 Think Fast Mutation # 486 Watch the Skies Mutation # 485 Death from Below
Brood War
General
No Rain in ASL20? Joined effort [ASL20] Ro24 Preview Pt2: Take-Off BW General Discussion Flash On His 2010 "God" Form, Mind Games, vs JD
Tourneys
[ASL20] Ro24 Group F [IPSL] CSLAN Review and CSLPRO Reimagined! [Megathread] Daily Proleagues [ASL20] Ro24 Group E
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates [G] Mineral Boosting Muta micro map competition
Other Games
General Games
General RTS Discussion Thread Stormgate/Frost Giant Megathread Nintendo Switch Thread Dawn of War IV Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine The year 2050 European Politico-economics QA Mega-thread
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
High temperatures on bridge(s) Gtx660 graphics card replacement Installation of Windows 10 suck at "just a moment"
TL Community
The Automated Ban List TeamLiquid Team Shirt On Sale
Blogs
Evil Gacha Games and the…
ffswowsucks
Breaking the Meta: Non-Stand…
TrAiDoS
INDEPENDIENTE LA CTM
XenOsky
[Girl blog} My fema…
artosisisthebest
Sharpening the Filtration…
frozenclaw
ASL S20 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1304 users

Computer Programming, compiling a shared library

Blogs > Zortch
Post a Reply
Zortch
Profile Blog Joined January 2008
Canada635 Posts
May 15 2008 15:59 GMT
#1
Hey, so I'm a math student working on a computer program.
I've got to call some C methods from my java code so I'm working on learning some basic JNI(java native interface).

I am working on Fedora.
I'm putting together the very simple HelloWorld program for starters.
I'm following along exactly with the book.
Java code is written fine, C code is written fine.
Now I need to compile HelloWorld.c into libHelloWorld.so but the book only gives commands to do this for Solaris and Win32. I tried the Solaris command but it didn't work.
The command given is:
cc -G -I/java/include -I/java/include/solaris HelloWorld.c -o libHelloWorld.so

The message I get is:
cc: unrecognized option '-G'
HelloWorld.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
HelloWorld.c:8: error: stray ‘\’ in program
HelloWorld.c:8: error: missing terminating " character

If anyone has any idea of the proper command or what I'm doing wrong I'd appreaciate it, Thanks!


*****
Respect is everything. ~ARchon
haduken
Profile Blog Joined April 2003
Australia8267 Posts
May 15 2008 16:05 GMT
#2
type: man cc
and look up for an option that does what you want.

dunno really...
going to sleep now, but just by looking at your problem for a few secs, it appears you are trying to
access something on solaris (a sun OS which has good java support) on fedora, a typical linux machine.

try dig around sun forum and see if they have something that you can install.
Rillanon.au
haduken
Profile Blog Joined April 2003
Australia8267 Posts
May 15 2008 16:22 GMT
#3
google says that JNI has platform dependencies....
have a look at this page
http://depth-first.com/articles/2006/10/16/compiling-c-to-java-bytecode

i'm guessing you have to change the -I/java/include -I/java/include/solaris into whatever java you got on your fedora...
Rillanon.au
zdd
Profile Blog Joined October 2004
1463 Posts
May 15 2008 16:30 GMT
#4
looks like your cc binary wasn't compiled with the proper flags. did you compile it from source or are you using a pre-built package?
All you need in life is a strong will to succeed and unrelenting determination. If you meet these prerequisites, you can become anything you want with absolutely no luck, fortune or natural ability.
Zortch
Profile Blog Joined January 2008
Canada635 Posts
May 15 2008 16:36 GMT
#5
zdd:
Ok well I don't really understand what you just said, but I assume you're talking about my fedora setup? I didn't set up anything on this computer if that is what you are asking.
Sorry for my lack of knowledge heh, I'm not really a comp sci student.

haduken:
Thanks for the advice, I'll look into it ^^
Respect is everything. ~ARchon
zdd
Profile Blog Joined October 2004
1463 Posts
Last Edited: 2008-05-15 16:45:16
May 15 2008 16:44 GMT
#6
On May 16 2008 01:36 Zortch wrote:
zdd:
Ok well I don't really understand what you just said, but I assume you're talking about my fedora setup? I didn't set up anything on this computer if that is what you are asking.
Sorry for my lack of knowledge heh, I'm not really a comp sci student.

haduken:
Thanks for the advice, I'll look into it ^^

generally "unrecognized option" in the output means that the program does not support the function you are trying to make it perform, because someone explicitly specified it at compile time by not setting a "flag" to the compiler that made your "cc" program, or the function has a different parameter than the one you are used to. so the -G is not supported by your cc, and since you are probably using the pre-built fedora cc package, I would recommend rebuilding cc from the source code with the flag for whatever feature "-G" is enabled, or finding out if the feature has to be called with a different parameter other than -G.
All you need in life is a strong will to succeed and unrelenting determination. If you meet these prerequisites, you can become anything you want with absolutely no luck, fortune or natural ability.
CTStalker
Profile Blog Joined November 2004
Canada9720 Posts
May 15 2008 16:46 GMT
#7
some very smart people i've worked with have told me that JNI is one the hardest APIs around to learn, so goodluck. I've only got minimal experience with it, so I'm not any help. sorry
By the way, my name is Funk. I am not of your world
omgbnetsux
Profile Blog Joined April 2004
United States3749 Posts
May 15 2008 16:49 GMT
#8
On May 16 2008 01:46 CTStalker wrote:
some very smart people i've worked with have told me that JNI is one the hardest APIs around to learn, so goodluck. I've only got minimal experience with it, so I'm not any help. sorry

JNI is nasty indeed. I won't even touch it.

Godspeed. Google, google, google.
FreeZEternal
Profile Joined January 2003
Korea (South)3396 Posts
May 15 2008 16:50 GMT
#9
Yeap it's very hard because you make a mistake in your C code and you will get huge native stack trace that will kill your JVM.
Zortch
Profile Blog Joined January 2008
Canada635 Posts
May 15 2008 16:50 GMT
#10
Heh, thanks guys.
The worst part is, JNI isn't even the problem...yet xD
Respect is everything. ~ARchon
borg
Profile Joined September 2005
171 Posts
May 15 2008 20:36 GMT
#11
hi there, lemme try to shed some light on this.

first of all, unix (solaris) isnt linux (fedora). you can easily tell from the man pages for any unix command and their linux counterpart. that's not to say they are completely different, sometimes the differences are very subtle, even undocumented...

that said, ill copy/paste the man pages for solaris 5.9 (which i have) for the cc command
+ Show Spoiler +

SunOS/BSD Compatibility Package Commands cc(1B)

NAME
cc - C compiler

SYNOPSIS
/usr/ucb/cc [options]

DESCRIPTION
/usr/ucb/cc is the interface to the BSD Compatibility Pack-
age C compiler. It is a script that looks for the link
/usr/ccs/bin/ucbcc to the C compiler. The /usr/ccs/bin/ucbcc
link is available only with the SPROcc package, whose
default location is /opt/SUNWspro. The /usr/ucb/cc interface
is identical to /usr/ccs/bin/ucbcc, except that BSD headers
are used and BSD libraries are linked before base
libraries. The /opt/SUNWspro/man/man1/acc.1 man page is
available only with the SPROcc package.

OPTIONS
The /usr/ucb/cc interface accepts the same options as
/usr/ccs/bin/ucbcc, with the following exceptions:

-Idir Search dir for included files whose names do not begin
with a slash (/) prior to searching the usual direc-
tories. The directories for multiple -I options are
searched in the order specified. The preprocessor
first searches for #include files in the directory
containing sourcefile, and then in directories named
with -I options (if any), then /usr/ucbinclude, and
finally, in /usr/include.

-Ldir Add dir to the list of directories searched for
libraries by /usr/ccs/bin/ucbcc. This option is passed
to /usr/ccs/bin/ld and /usr/lib. Directories specified
with this option are searched before /usr/ucblib and
/usr/lib.

-Y P, dir
Change the default directory used for finding
libraries.

EXIT STATUS
The following exit values are returned:

0 Successful compilation or link edit.

>0 An error occurred.

FILES
/usr/ccs/bin/ld
link editor

/usr/lib/libc

SunOS 5.9 Last change: 24 Feb 1998 1

SunOS/BSD Compatibility Package Commands cc(1B)

C library

/usr/ucbinclude
BSD Compatibility directory for header files

/usr/ucblib
BSD Compatibility directory for libraries

/usr/ucblib/libucb
BSD Compatibility C library

/usr/lib/libsocket
library containing socket routines

/usr/lib/libnsl
library containing network functions

/usr/lib/libelf
library containing routines to process ELF object
files

/usr/lib/libaio
library containing asynchronous I/O routines

ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:

____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Availability | SUNWscpu |
|_____________________________|_____________________________|

SEE ALSO
ld(1), a.out(4), attributes(5)

NOTES
The -Y P, dir option may have unexpected results and should
not be used.

SunOS 5.9 Last change: 24 Feb 1998 2

>





and here's the man page for cc from my linux OS (ubuntu):
(incidentally, cc is linked to gcc)

+ Show Spoiler +

GCC(1) GNU GCC(1)



NAME
gcc - GNU project C and C++ compiler

SYNOPSIS
gcc [-c|-S|-E] [-std=standard]
[-g] [-pg] [-Olevel]
[-Wwarn...] [-pedantic]
[-Idir...] [-Ldir...]
[-Dmacro[=defn]...] [-Umacro]
[-foption...] [-mmachine-option...]
[-o outfile] [@file] infile...

Only the most useful options are listed here; see below for the remain‐
der. g++ accepts mostly the same options as gcc.

DESCRIPTION
When you invoke GCC, it normally does preprocessing, compilation,
assembly and linking. The "overall options" allow you to stop this
process at an intermediate stage. For example, the -c option says not
to run the linker. Then the output consists of object files output by
the assembler.

Other options are passed on to one stage of processing. Some options
control the preprocessor and others the compiler itself. Yet other
options control the assembler and linker; most of these are not docu‐
mented here, since you rarely need to use any of them.

Most of the command line options that you can use with GCC are useful
for C programs; when an option is only useful with another language
(usually C++), the explanation says so explicitly. If the description
for a particular option does not mention a source language, you can use
that option with all supported languages.

The gcc program accepts options and file names as operands. Many
options have multi-letter names; therefore multiple single-letter
options may not be grouped: -dr is very different from -d -r.

You can mix options and other arguments. For the most part, the order
you use doesn’t matter. Order does matter when you use several options
of the same kind; for example, if you specify -L more than once, the
directories are searched in the order specified.

Many options have long names starting with -f or with -W---for example,
-fmove-loop-invariants, -Wformat and so on. Most of these have both
positive and negative forms; the negative form of -ffoo would be
-fno-foo. This manual documents only one of these two forms, whichever
one is not the default.

OPTIONS
Option Summary

Here is a summary of all the options, grouped by type. Explanations
are in the following sections.

Overall Options
-c -S -E -o file -combine -pipe -pass-exit-codes -x language
-v -### --help --target-help --version @file

C Language Options
-ansi -std=standard -fgnu89-inline -aux-info filename -fno-asm
-fno-builtin -fno-builtin-function -fhosted -ffreestanding
-fopenmp -fms-extensions -trigraphs -no-integrated-cpp
-traditional -traditional-cpp -fallow-single-precision
-fcond-mismatch -fsigned-bitfields -fsigned-char -funsigned-bit��‐
fields -funsigned-char

C++ Language Options
-fabi-version=n -fno-access-control -fcheck-new -fconserve-space
-ffriend-injection -fno-elide-constructors -fno-enforce-eh-specs
-ffor-scope -fno-for-scope -fno-gnu-keywords -fno-implicit-tem��‐
plates -fno-implicit-inline-templates -fno-implement-inlines
-fms-extensions -fno-nonansi-builtins -fno-operator-names
-fno-optional-diags -fpermissive -frepo -fno-rtti -fstats
-ftemplate-depth-n -fno-threadsafe-statics -fuse-cxa-atexit
-fno-weak -nostdinc++ -fno-default-inline -fvisibil��‐
ity-inlines-hidden -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor
-Wreorder -Weffc++ -Wno-deprecated -Wstrict-null-sentinel
-Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual
-Wno-pmf-conversions -Wsign-promo

Objective-C and Objective-C++ Language Options
-fconstant-string-class=class-name -fgnu-runtime -fnext-runtime
-fno-nil-receivers -fobjc-call-cxx-cdtors -fobjc-direct-dispatch
-fobjc-exceptions -fobjc-gc -freplace-objc-classes -fzero-link
-gen-decls -Wassign-intercept -Wno-protocol -Wselector
-Wstrict-selector-match -Wundeclared-selector

Language Independent Options
-fmessage-length=n -fdiagnostics-show-location=[once|every-line]
-fdiagnostics-show-option

Warning Options
-fsyntax-only -pedantic -pedantic-errors -w -Wextra -Wall
-Waddress -Waggregate-return -Wno-attributes -Wc++-compat
-Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconver��‐
sion -Wno-deprecated-declarations -Wdisabled-optimization
-Wno-div-by-zero -Wno-endif-labels -Werror -Werror=* -Wer��‐
ror-implicit-function-declaration -Wfatal-errors -Wfloat-equal
-Wformat -Wformat=2 -Wno-format-extra-args -Wformat-nonliteral
-Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-func��‐
....


there's actually like 20 more pages of detailed info, but you can see that already there are huge differences btwn the two commands.

since all you're doing is just a hello world program to learn the basics, the best way would be to get a different book that is gives you examples specifically for the OS you're using, that way you dont have to tackle these problems and can just get on with learning the programming language.

i'm guessing your book is this:
http://java.sun.com/docs/books/jni/html/start.html

and according to the book,
The -G option instructs the C compiler to generate a shared library instead of a regular Solaris executable file.

when i look for the "shared library" keyword in the manpage for my linux OS, i see that there are some flags that probably do the same thing, look for -shared, -shared-libgcc, -static-libgcc

you can do a man on your own cc, and look for this "shared library" keyword and work out the corresponding flag that you need.
borg
Profile Joined September 2005
171 Posts
Last Edited: 2008-05-15 20:46:37
May 15 2008 20:39 GMT
#12
one other solution that might also help you is that if you're deadset in using solaris, you can run it as a virtual environment under fedora or any other OS.

here's the vmware version of it for solaris 10.

http://www.vmware.com/appliances/directory/420

you should know that this requires installing the vmware (player) software on fedora (shouldnt be that hard) first and then running the vmware image for solaris 10.

vmware and the solaris image are both free.
Please log in or register to reply.
Live Events Refresh
Afreeca Starleague
10:00
Round of 24 / Group F
hero vs Alone
Royal vs Barracks
Afreeca ASL 8371
sctven
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Harstem 272
StarCraft: Brood War
Britney 31050
Calm 12217
Sea 3247
Jaedong 2943
Bisu 2720
Rain 2130
Flash 1908
Horang2 1563
BeSt 734
EffOrt 637
[ Show more ]
actioN 501
ZerO 397
Pusan 353
Mini 296
Larva 270
ggaemo 194
Hyun 193
Mong 172
Soulkey 142
Last 126
Hyuk 114
Backho 84
PianO 72
ToSsGirL 59
Liquid`Ret 41
TY 39
soO 36
Killer 36
JYJ35
Sharp 35
Icarus 22
ajuk12(nOOB) 19
Sacsri 18
Terrorterran 14
NaDa 13
Sexy 13
JulyZerg 12
SilentControl 10
scan(afreeca) 10
HiyA 8
ivOry 6
Beast 3
Light 0
Dota 2
Dendi607
qojqva545
XaKoH 335
BananaSlamJamma195
XcaliburYe149
KheZu57
Counter-Strike
olofmeister1852
fl0m1774
x6flipin495
edward32
Other Games
singsing2061
B2W.Neo1155
crisheroes325
Pyrionflax325
Fuzer 267
SortOf157
ArmadaUGS34
Dewaltoss23
MindelVK9
Organizations
StarCraft: Brood War
UltimateBattle 215
lovetv 8
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 14 non-featured ]
StarCraft 2
• StrangeGG 64
• LUISG 29
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV263
League of Legends
• Jankos795
Upcoming Events
Replay Cast
12h 25m
The PondCast
22h 25m
WardiTV Summer Champion…
23h 25m
Clem vs Classic
herO vs MaxPax
Replay Cast
1d 12h
LiuLi Cup
1d 23h
MaxPax vs TriGGeR
ByuN vs herO
Cure vs Rogue
Classic vs HeRoMaRinE
Cosmonarchy
2 days
OyAji vs Sziky
Sziky vs WolFix
WolFix vs OyAji
BSL Team Wars
2 days
Team Hawk vs Team Dewalt
BSL Team Wars
2 days
Team Hawk vs Team Bonyth
SC Evo League
3 days
TaeJa vs Cure
Rogue vs threepoint
ByuN vs Creator
MaNa vs Classic
Maestros of the Game
3 days
ShoWTimE vs Cham
GuMiho vs Ryung
Zoun vs Spirit
Rogue vs MaNa
[ Show More ]
[BSL 2025] Weekly
3 days
SC Evo League
4 days
Maestros of the Game
4 days
SHIN vs Creator
Astrea vs Lambo
Bunny vs SKillous
HeRoMaRinE vs TriGGeR
BSL Team Wars
4 days
Team Bonyth vs Team Sziky
BSL Team Wars
4 days
Team Dewalt vs Team Sziky
Monday Night Weeklies
5 days
Replay Cast
5 days
Sparkling Tuna Cup
5 days
Liquipedia Results

Completed

CSLAN 3
uThermal 2v2 Main Event
HCC Europe

Ongoing

Copa Latinoamericana 4
BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Qualifiers
ASL Season 20
CSL Season 18: Qualifier 1
Acropolis #4 - TS1
CSL Season 18: Qualifier 2
SEL Season 2 Championship
WardiTV Summer 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025

Upcoming

CSL 2025 AUTUMN (S18)
LASL Season 20
BSL Season 21
BSL 21 Team A
Chzzk MurlocKing SC1 vs SC2 Cup #2
RSL Revival: Season 2
Maestros of the Game
EC S1
Sisters' Call Cup
IEM Chengdu 2025
PGL Masters Bucharest 2025
MESA Nomadic Masters Fall
Thunderpick World Champ.
CS Asia Championships 2025
Roobet Cup 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.