Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7890293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:19:04+00:00 2026-06-03T06:19:04+00:00

I have successfully installed WordNet library. Now I am trying to use the library

  • 0

I have successfully installed WordNet library. Now I am trying to use the library in a program, but I cannot get a sample program to build. I get linker errors (undefined reference) even though the library search path is correct.

Here is the error:

gcc -g -I/usr/local/WordNet-3.0/include  -o wordnet_sample.o -c wordnet_sample.c
gcc -L/usr/local/WordNet-3.0/lib -lWN -o wordnet_sample wordnet_sample.o
wordnet_sample.o: In function `main':
/home/user/wordnet_sample/wordnet_sample.c:6: undefined reference to `wninit'

This is the Makefile

WORDNET_INSTALL=/usr/local/WordNet-3.0
CFLAGS=-g -I$(WORDNET_INSTALL)/include
LDFLAGS=-L$(WORDNET_INSTALL)/lib -lWN

wordnet_sample: wordnet_sample.o
        gcc $(LDFLAGS) -o wordnet_sample wordnet_sample.o

wordnet_sample.o: wordnet_sample.c
        gcc $(CFLAGS) -o wordnet_sample.o -c wordnet_sample.c

This is the sample program

#include <wn.h>
#include <stdlib.h>
int main(int argc, char **argv) {
    int isOpen = 0 == wninit();
    if (isOpen) {
            printf("wordnet opened!\n");
    }
    else {
            printf("Could not open WordNet dictionary!\n");
    }
    return 0;
}

The WordNet library is installed

[user@local wordnet_sample]$ ls -l /usr/local/WordNet-3.0/lib/
total 180
-rw-r--r-- 1 root root 172344 May  3 15:34 libWN.a
drwxr-xr-x 2 root root   4096 May  3 15:34 wnres

I suspect that I may need more arguments to the linker, but I am really not sure. Does anyone come across this? Does anyone know why the undefined reference error is happening even though I have the right library and library search path?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:19:05+00:00Added an answer on June 3, 2026 at 6:19 am

    You need to add -c to CFLAGS.

    Also the first gcc command needs to have the libraries after the objects. You may put LDFLAGS in the end:

    gcc -o wordnet_sample wordnet_sample.o $(LDFLAGS)
    

    Better yet, have separate LDFLAGS (linker options) and LIBS (actual libraries to link). So:

    LDFLAGS=-L$(WORDNET_INSTALL)/lib
    LIBS=-lWN
    ....
    gcc $(LDFLAGS) -o wordnet_sample wordnet_sample.o $(LIBS)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use jqplot http://www.jqplot.com/tests/cursor-highlighter.php . I have successfully installed it in
I have successfully installed Phing but have a few questions. Right now, in order
I have successfully built and installed the opencv lib. Now I am trying to
I have successfully installed lightbox module in drupal and now using it for 'sign
I have successfully installed mercurial on media temple grid server. But I can not
Trying to get the gem mysql2 installed on ubuntu and I have tried all
I am recently have been successfully installed NetBean 6.8 on Ubuntu Box (10.04). But
I have successfully downloaded and installed AJAX framework, and the control toolkit. While trying
I have successfully installed an ODBC driver. I am trying to connect to an
I'm a Drupal newbie, but have successfully installed it at a CentOS 5.5 Linux,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.