Can's compile the gdbm program ?(SOLVED)

Here is an example comes from Beginning Linux Programming 3rd ,and I can't compile it on my machine. I don't know why?? And the gdbm package is always in the base. Please help me.
try compile 1:
$gcc dbm1.c -o gdbm1 -lgdbm
错误信息:
/tmp/cc2vMknU.o: In function `main':
dbm1.c: (.text+0x2d): undefined reference to `dbm_open'
dbm1.c: (.text+0x244): undefined reference to `dbm_store'
dbm1.c: (.text+0x2ee): undefined reference to `dbm_fetch'
dbm1.c: (.text+0x379): undefined reference to `dbm_close'
collect2: ld returned 1 exit status
try compile 2:
$ gcc dbm1.c -o gdbm1 -lndbm -L/usr/lib
错误信息:
/usr/bin/ld: cannot find -lndbm
collect2: ld returned 1 exit status
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <ndbm.h>
#include <string.h>
#define TEST_DB_FILE "/tmp/dbm1_test"
#define ITEMS_USED 3
/* A struct to use to test dbm */
struct test_data {
char misc_chars[15];
int any_integer;
char more_chars[21];
int main() {
struct test_data items_to_store[ITEMS_USED];
struct test_data item_retrieved;
char key_to_use[20];
int i, result;
datum key_datum;
datum data_datum;
DBM *dbm_ptr;
dbm_ptr = dbm_open(TEST_DB_FILE, O_RDWR | O_CREAT, 0666);
if (!dbm_ptr) {
fprintf(stderr, "Failed to open database\n");
exit(EXIT_FAILURE);
/* put some data in the structures */
memset(items_to_store, '\0', sizeof(items_to_store));
strcpy(items_to_store[0].misc_chars, "First!");
items_to_store[0].any_integer = 47;
strcpy(items_to_store[0].more_chars, "foo");
strcpy(items_to_store[1].misc_chars, "bar");
items_to_store[1].any_integer = 13;
strcpy(items_to_store[1].more_chars, "unlucky?");
strcpy(items_to_store[2].misc_chars, "Third");
items_to_store[2].any_integer = 3;
strcpy(items_to_store[2].more_chars, "baz");
for (i = 0; i < ITEMS_USED; i++) {
/* build a key to use */
sprintf(key_to_use, "%c%c%d",
items_to_store[i].misc_chars[0],
items_to_store[i].more_chars[0],
items_to_store[i].any_integer);
/* build the key datum strcture */
key_datum.dptr = (void *)key_to_use;
key_datum.dsize = strlen(key_to_use);
data_datum.dptr = (void *)&items_to_store[i];
data_datum.dsize = sizeof(struct test_data);
result = dbm_store(dbm_ptr, key_datum, data_datum, DBM_REPLACE);
if (result != 0) {
fprintf(stderr, "dbm_store failed on key %s\n", key_to_use);
exit(2);
} /* for */
/* now try and retrieve some data */
sprintf(key_to_use, "bu%d", 13); /* this is the key for the second item */
key_datum.dptr = key_to_use;
key_datum.dsize = strlen(key_to_use);
data_datum = dbm_fetch(dbm_ptr, key_datum);
if (data_datum.dptr) {
printf("Data retrieved\n");
memcpy(&item_retrieved, data_datum.dptr, data_datum.dsize);
printf("Retrieved item - %s %d %s\n",
item_retrieved.misc_chars,
item_retrieved.any_integer,
item_retrieved.more_chars);
else {
printf("No data found for key %s\n", key_to_use);
dbm_close(dbm_ptr);
exit(EXIT_SUCCESS);
Last edited by 009lin (2007-08-19 02:29:54)

GDBM includes dbm and ndbm compatability.
I found the solution from the man page, it said:
If you wish to use the dbm or ndbm  compatibility  routines,  you  must
       link in the gdbm_compat library as well.  For example:
            gcc -o prog proc.c -lgdbm -lgdbm_compat
Last edited by 009lin (2007-08-19 02:29:27)

Similar Messages

  • After getting an update from 10.6.8 many of my programs were no longer able to open. How can I undo the update or solve this problem another way?

    After getting an update from 10.6.8 many of my programs were no longer able to open. How can I undo the update or solve this problem another way?

    Do you have a bootable clone from prior to the update? If so, roll back with that.
    Are your apps that won't open PPC and do they need Rosetta? Do you need to activate Rosetta?
    Have you considered reinstalling 10.6 from your install disc and then coming forward with the 10.6.8 Combo Updater, then doing software update and not including whatever it was you installed that caused this propblem?
    By the way - what update was it that caused this problem?

  • How can i compile the program?

    hi,everybody:
    I have a program which include the next statments:
    public void println(boolean flag)
    throws IOException
    Object obj = lock;
    obj;
    JVM INSTR monitorenter ;
    print(flag);
    newLine();
    obj;
    JVM INSTR monitorexit ;
    break MISSING_BLOCK_LABEL_26;
    Exception exception;
    exception;
    obj;
    JVM INSTR monitorexit ;
    throw exception;
    how can i compile the program?
    thanks

    Hi,
    I'm trying to figure out how to use this decompiler, I have downloaded it to windows 2000 platform and it unzips to 1 file with extension "1-bin" - OS doesn.'t know what to do with and neither do I ;) - I'm starting out on something here and this tool would be useful.
    Thanks for any install instructions you might have.
    mufc1999
    Hi,
    I've had a similiar problem with decompiling certain
    classes. Try the following decompiler,
    http://jrevpro.sourceforge.net, after using this one,
    the code decompiled fine, this tool is also a
    disassembler and quite a nifty one i might add. :)
    Hope this helps!
    Have Fun!

  • Error 8 when compiling the upload program: row 436

    Hi all,
    pls let me know how to solve this error
    Error 8 when compiling the upload program: row 436, message: A newer version of data type /BIC/B0000582000 was
    Thanks
    Prashant

    Hello SAP gurus.
    I know it's a very long time the question was asked, but who cares if it can someday help somebody?
    So i just faced the same issue, the solution was sample, i relaunch RSA1 and the problem was solved.
    Hope i would be helpful
    Salah

  • HT6030 I have many problems with my mail since I moved to mavericks. The filter is very sensitive, read mail appears as unread, I can't drag mail to the folders and more. I can't update the mail program as directed on this page, update says my system is u

    I have many problems with my mail since I moved to mavericks. The filter is very sensitive, read mail appears as unread, I can't drag mail to the folders and more. I can't update the mail program as directed on this page, update says my system is updated

    I don't think that a software update from Apple will solve the issues that you are having. You have a rogue installation. After you posted I have just done the following:
    Disk Utility can verify  my partitioned Volume (including my boot disk) AND REPAIR the non-boot disks on the same Volume without a glitch. It repairs the non-boot disks containing data smoothly.
    I have used Mail to send some mails from some Yahoo and Hotmail accounts to my Thunderbird client containing GMail accounts - absolutely normal.
    I have iLife '09 but my iMovie '09 and iPhoto '09 open in a jiffy and I see no issues here. I have 6GB RAM (Maximum) on an early 2008 Macbook Pro with a 750GB hard drive partitioned with 120GB reserved for the Boot Drive.
    I am sorry that I cannot help further but I am sure there must be a way to reinstall the software without having to revert to restoring your ML backup. I have two clones and if you have such I would attempt to do that through that rather than through Time Machine - that is of course if you have a cloned drive.
    Good luck!

  • Error when compiling the upload program (Message no. RSAR233)

    Hello,
    I tried to upload data from a flatfile but I did modified the Comm.Structure, Trans.Structure and Transfer Rules.
    After <u><b>activating</b></u> the all changes, I check data from InfoPackage by previewing it. Unfortunately, I got the follow messages from the popup window:
    Error 8 when compiling the upload program: row
    227, message: Data type /BIC/CCABTWJI_STK01 was
    found in a newer
    I got this kind of problems many times. I solved it by create a new infosource and everything again. I don't think it's good idea to do this way.
    Any better solution would be sincerely appreciated?
    -WJ-

    Another solution:
    go out the transaction RSA1 ans return to the transaction RSA1 again.
    This would help for me without restarting anything.
    Thank you very much for all suggestion.
    -WJ-

  • Excel extractor produces error "Error 8 when compiling the upload program"

    I am trying to test a new Excel extractor I've created but when I do so I get the following error:
    RSAR233
    Error 8 when compiling the upload program: row 446, message: A newer version of data type /BIC/B0000788000 was
    I've tried reactivating transfer structures and transfer rules but with no success. When I activate the transfer structures I can see in the status bar briefly a message refering "Activating Structure /BIC/B0000788000". I am assuming it's the technical name of the structure which supports the extraction.
    Any ideas?
    Thanks for the help.

    OK, I can see your point. The Communication structure fields have data types, CHAR, CURR and DATS (those are the data types for the info-objects I am trying to load).
    But if I try to assign the same data types to the objects of the transfer structure which match the flat file I get errors like "Invalid data type (DATS) for source systems of type Ext. System.". What I understand this means is that I cannot use data types other than CHAR in the flat file structure so how can I assign data from a CHAR flat file to a DATS destination object? Do I need some kind of conversion? How? Do I really need a routine in the transfer rules?

  • PLEASE HELP!!  HOW DO YOU COMPILE THE HELLO PROGRAM?

    Hi everybody,
    I just install j2sdk1.4.1_01 on my RH 8. And it's install under the directory /usr/j2sdk1.4.1_01 Now, I was compiling the hello program under /home/JAVATEST
    and it gives me the following error
    Exception in thread "main" java.lang.NoClassDefFoundError: hello
    Could anyone please help me on how to solve this problem. I have try to setup CLASSPATH under .bash_profile as this:
    JAVA_HOME=/usr/j2sdk1.4.1_01
    export JAVA_HOME
    CLASSPATH=./:$JAVA_HOME/lib
    export CLASSPATH
    and still. It would still give me the error. Would anybody please help me on it?? Thanks. I need to do my homework soon. ^<^ thanks

    I think it's your program.
    it's I believe like this isn't it?
    // Put this in a file called hello.java
    public class hello
        public static void main(String args[])
            System.out.println("Hello world!");
        }Try compiling this with the following command : @home>javac hello.java
    then run the command with : @home>java hello
    It should run just like that

  • How can we disable the 'Improvement Program' from all the apps in TCS5?

    How can we disable the 'Improvement Program' from all the apps in TCS5, so that the end users are not able to see the option in the help menu?
    We have tried changing the value of bUsageMeasurement (HKLM\SOFTWARE\Policies\Adobe\(product name)\(version)\FeatureLockdown) to zero, but it did not help.

    You’re probably going to have to contact Support on that one.

  • If I have 2 tv's and each their own apple tv can I display the same program to them from my macbook at the same time?

    If I have 2 tv's and each their own apple tv can I display the same program to them from my macbook at the same time?
    for instance Keynote?

    Welcome to the Apple community.
    The Apple TV cannot display keynote presentations or websites from the computer. It can display them via mirroring from the iPad 2 or better or the iPhone 4S.
    You cannot AirPlay to 2 Apple TV 2's at the same time from an iOS device. You can watch the same video, TV show or listen to the same music from your iTunes library on multiple Apple TV's at the same time.

  • Error 8 when compiling the upload program: row

    Error 8 when compiling the upload program: row
    248, message: Data type /BIC/CCAWSAI_CID_TEXT was
    found in a new
    kindly help me out pls

    Hi Raghu,
    Error 8 Implies
    The last words should be read as "was found in a newer version".
    The system says that the active version of your Infosource is older then another version.
    I'd recommend to delete Infosource - Source system assignment (with PSA tables etc.).
    Then save (activate) the Infosource (communication structure). Then assign source system, create infopackage and load data again.
    else..
    Goto se38 and Run the program RS_TRANSTRU_ACTIVATE_ALL and relogin..
    Plz look the link.
    [Error when compiling the upload program (Message no. RSAR233) ]
    Hope this helps...
    Regards,
    NR
    Assign points if helpful...

  • Error 8 when compiling the upload program

    When loading data to the Infocube it gives the following error
    "Error 8 when compiling the upload
    227, message: Data type /BIC/CCFBZ
    found in a ne   "                 
    It doesnot go any further from thr infopackage also..

    Error when compiling the upload program (Message no. RSAR233)

  • Where can we find the standard program for scripts and smartform for vl02

    where can we find the standard program for scripts and smartform for vl02
    regard,
    anil

    If it is a standard Script Output see that all config in NACE tcode was done correctly and in the Application document the output type was properly defined and attached to a medium, partner and all communication related things like printer name, when to print the output and number of messages etc are entered in the document
    the go to the related application Tcode
    (for sales order goto VA02 or VA03)
    (delivery -VL02N or VL03N)
    for Invoice VF02 or VF03
    for PO -goto ME9F
    enter doc number, Issue Output to -> screen/printer
    then see the output
    step 1 : copy the z layout into testing client thru SCC1.
    step2 : go to se71 and check modified layout.
    step3 : if it is under logistics.. go to TCODE "NACE".
    u will see various applictions for each business process.
    there u have configure ur related layout according to requirments,
    for example u consider for Request fo Quatation..
    there is APPLICATION called "EA"
    click and enter into it. configure it with ur requirments, for help consult with ur functonal consaltant, and save it.
    step 4 : goto tcode ME9A for requst for quatation(RFQ).
    step 5 : enter test data avalable and check it with message display.
    it is same for other applications like Contract agreament --> ME9k
    invoice --> vl02n
    and goes on..
    Reward points for useful Answers

  • Can we debug the RFID programs ?

    Hello All,
    This is Rajani.
    I am working on a support project.
    I have a doubt. Can we debug the RFID programs ?

    Hi Rajani. Debug of RFID programs is possible. For your custom written code you can use the following code.
    start of code for debugging ***
       data: wf_break type i.
        while wf_break is initial.
        endwhile.
    end of code for debugging  ***
    You run the AII test tool to send tag information to AII. Then once the process starts to run, you can run the transaction sm50 in AII, to select that process and debug that process. Since the above is a while loop change the wf_break value to anything other than 0, and use the debugging keys to do your work.

  • I recently purchased a small restaurant and am wondering if anyone can tell me the best programs to maintain vendor bills,payroll,menu sales tracking etc. it's got to be easy to use! any suggestions?

    i recently purchased a small restaurant and am wondering if anyone can tell me the best programs to maintain vendor bills,payroll,menu sales tracking etc. it’s got to be easy to use! any suggestions?

    Bento - the database manager from FilePro.
    They have a large number of free templates to cover a number of different purposes.
    Allan

Maybe you are looking for

  • How do I maintain data and selection in a SWF after AutoDetach() is called?

    To date, the behaviour of my Flex panel has been based on the old CS4 sample, which stroked boxes using a thickness value specified in a combobox. Now I need to change the behaviour, but I'm not sure how to go about it. At the moment the SWF file is

  • JRE doesn't find TcpConnection.class

    Hi. I've got a problem using the email-function of the UTL_SMTP package. I copied the example from the Documentation and tried to make it work, but if i start it following Error occures: ORA-29540: Class oracle/plsql/net/TCPConnection not found ORA-0

  • WoodtypeOrnamentsStd Font on Mac

    Hi, I just purchased this font. I've followed the installation instructions, placing the .otf file in Mac HD>Library>Fonts>, with all the other font files. The name appears correctly in Adobe product font lists, but does not give the correct characte

  • How to reposition subtitles in Quicktime?

    Hello community, I am wondering if there is a way to reposition subtitles in Quicktime player and then re-export as an MP4 file for the iPad.  Currently the subtitles appear at the bottom of the screen, and I want them to appear at the top.  Does any

  • Swap table data using Update query

    Hi,       If I have a table T with 4 rows & 2 columns A & B. A has values 1,2,3,4. and B has 10,20,30,40.  A  B  1  10  2  20  3  30  4  40 Write an Update SQL query which will Swap the values of A & B for all records. (Do not use a sub-query) I face