Linux Linker Troubles

Started by
4 comments, last by C-Junkie 19 years, 3 months ago
My linker is crapping out on me, any idea?

#include <fstream>
#include <iostream>
int main(){
        std::ifstream("in");
        std::cout << "test" << std::endl;
        return 0;
}

gcc test.cpp

/tmp/ccQ6y4Jd.o(.text+0x25): In function `main':
: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream[in-charge](char const*, std::_Ios_Openmode)'
/tmp/ccQ6y4Jd.o(.text+0x37): In function `main':
: undefined reference to `std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream [in-charge]()'
/tmp/ccQ6y4Jd.o(.text+0x42): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/ccQ6y4Jd.o(.text+0x4f): In function `main':
: undefined reference to `std::cout'
/tmp/ccQ6y4Jd.o(.text+0x54): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccQ6y4Jd.o(.text+0x5d): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccQ6y4Jd.o(.text+0x8a): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccQ6y4Jd.o(.text+0xb9): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccQ6y4Jd.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

Advertisement
Try g++ test.cpp
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
I love you!

It works, I'm so silly, except
/usr/local/bin/g++ and /usr/local/bin/gcc are both symlinks to
/usr/bin/colorgcc

So what gives? :)
I have a FAT partition mounted to my Programming/ folder and when I copy the executable there I can't run it. All the permissions are set.
But it says---> bash: ./a.out: Permission denied

Does Linux not have the ability to run programs from a separate partition?
Quote:Original post by Boder
It works, I'm so silly, except
/usr/local/bin/g++ and /usr/local/bin/gcc are both symlinks to
/usr/bin/colorgcc

So what gives? :)

Programs will get the path passed to them, so they can tell what filename you used to run them and thus produce the correct functionality. Quite a few Linux programs do this.

Quote:Original post by Boder
I have a FAT partition mounted to my Programming/ folder and when I copy the executable there I can't run it. All the permissions are set.
But it says---> bash: ./a.out: Permission denied

Does Linux not have the ability to run programs from a separate partition?

I'm not entirely sure about executing code but in my experience FAT does not store permissions with files unless it's set up to do so (which is a hack). You'll probably need to change some permissions in /etc/fstab to allow access to users less privileged than root.
Ra
it is, more than likely, mounted with the noexec option.

This topic is closed to new replies.

Advertisement