• Advertisement
Sign in to follow this  

Linux Linker Troubles

This topic is 4769 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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? :)

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement