Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    5

    Question C++ Segmentation Fault

    I'm planning to use C++ for some CGI functions. So just to make sure the basics worked after installing GCC, I wrote a simple Hello World, just a one-liner to write to cout. Got a seg fault!

    I backed down all the way to simple C, stdio.h, and printf() -- works fine.

    The seg fault happens if I take that very simple program and add one line:
    #include <iostream>

    Weird.

    Anyone else out there using C++? Any hints on how to include iostream header and make it work?

    Thanks,

    Sam

  2. #2
    Junior Member
    Join Date
    May 2010
    Posts
    5

    Default

    Problem solved. I had to use static linking, as in:

    g++ -static -o simple1 simple1.cpp

    Now, if anyone knows how to get shared libraries to work, that's my next question! I did try setting LD_LIBRARY_PATH=/usr/lib but that didn't help.
    Last edited by samssc; 06-01-2010 at 07:49 PM.

  3. #3
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,721

    Default

    Would adding /usr/lib to your /etc/ld.so.conf file do anything. I really have very little knowledge in this area but I do know when I install something in a non traditional location, that I add the path there to get it to link up correctly.

    I can't follow everything on this page but it sounds like you have more experience in this area so it might give you more insight in what you need for your particular project. http://tldp.org/HOWTO/Program-Librar...libraries.html
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  4. #4
    Junior Member
    Join Date
    May 2010
    Posts
    5

    Unhappy

    Thanks. Just checked /etc/ld.so.conf, and /usr/lib is already there, along with several other standard lib directories.

    So, linking shared lib is still a mystery.... Guess I'll get by with static link for now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •