[SOLVED] GCC returns error, even though the code works.

# Edit: 0740 // 7.1.14
# Thanks to Hurricane for his answer.
# If you came here with the same question, simply replace 'gcc' with 'g++'.
# Many thanks to all who answered.
I'm new to arch but have used GCC on windows before. I decided to try a simple hello world program (~/code/hello.cpp) but when I went to make an executable, I get the following error:
[simple@arch ~]$ gcc ~/code/hello.cpp -o ~/code/exe/hello
/tmp/ccUO8tkq.o: In function `main':
hello.cpp:(.text+0xa): undefined reference to `std::cout'
hello.cpp:(.text+0xf): 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*)'
hello.cpp:(.text+0x14): 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> >&)'
hello.cpp:(.text+0x1c): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/tmp/ccUO8tkq.o: In function `__static_initialization_and_destruction_0(int, int)':
hello.cpp:(.text+0x4a): undefined reference to `std::ios_base::Init::Init()'
hello.cpp:(.text+0x59): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
For reference, here is the code in hello.cpp
#include <iostream>
using namespace std;
int main()
cout << "Hello world!" << endl;
return 0;
I've tried to make sense of the error, but I don't understand it.
Any help is greatly appreciated. Thank you.
Last edited by simplesquare (2014-01-05 12:41:55)

g++ ~/code/hello.cpp -o ~/code/exe/hello
That should do the trick.
GCC is just a front-end that chooses the right compiler depending on the suffix of the file(s) being passed in.
The problem with using GCC to compile a C++ program is that it' won't link C++ by default. If you noticed,
what returned the error was ld, which is the GNU linker.

Similar Messages

  • I have uninstalled and installed the latest Flash Player 17 many times.  I am currently working on a yearbook site that gets locked every time I try to add photos.  I have also received a plug in error even though the plug in box is checked.  I have a Mac

    I have uninstalled and installed the latest Flash Player 17 many times.  I am currently working on a yearbook site that gets locked every time I try to add photos.  I have also received a plug in error even though the plug in box is checked.  I have a MacBook Pro.  Please help!!!

    To give you any useful advice, I'm going to need to know more about your computer and browser:
    https://forums.adobe.com/message/5249945#5249945

  • Cannot Log-On even though the internet works fine?

    Cannot Log-On even though the internet works fine? I have not made any changes to my system. Anyone else having the same problem. My handle is an AIM handle, if this helps. Is it because its the first of a new year?
    Thanks in Advance!
    Mark

    I found out its my IM archiving company thats is down. Global Relay.
    Thanks anyway!
    Mark

  • TS1424 trying to rent a movie through itunes on my apple TV and I continue to get a payment verification error even though the payment information is correct and the bank authorizes the purchase?

    What is the solution to problem renting movie through itunes on apple TV when payment verification not accepted even though the bank authorizes the payment?

    If you are also getting a message to contact iTunes Support then you can do so via this link and ask them why the message is appearing (we are fellow users here on these user-to-user forums, we won't know why) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • Logic Sputtering, CPU spiking horribly for no apparent reason, gives MIDI sync error even though the computer is set at the same sample rate.

    It's literally making it impossible for me to produce anything, after what seems an arbitrary amount of time in Logic my audio will begin to distort and I will get errors stating that my MIDI sample rates don't match, but they DO and it will spit out some seemingly random sample rate from nowhere. My CPU usage will spike and even my cursor will jitter across the screen until it stops stuttering. The audio problem seems to only be caused by Logic but will sometimes continue to occur in other applications after Logic is closed.
    How on earth do I fix this? It's making it impossible for me to work on remixes that I have to have finished soon, I have deadlines and I simply can't work in these conditions... the audio doesn't work.

    That sample rate error comes up when Logic gets out of sync internally, you will sometimes also see a MIDI/Audio sync error. MIDI timing is taken from the audio driver/sample rate, it's what enables MIDI to stay in sync with audio, when the audio/MIDI engines get out of whack these are the kind of errors that pop up. (there doesn't have to be any MIDI in the song)  Can be caused by bad drivers, interference from another running program, synchronization settings, bad or incompatible plugins!

  • WEBI Report returns results even though the Infocube is empty

    Hi all!
    I have the following problem with WebIn report refresh functionality:
    Step 1 -> I run my WebIn report this way: double click on my folder >> double click on my WebIn report >> the prompt values     pop-up appears and I choose a given MONTH and click RUN. After that, my report brings some values that are stored in the infocube. No problem SO FAR!
    Step 2 -> I go to RSA1 in BW and clean the infocube, leaving it without registers.
    Step 3 -> I do STEP 1 again and my WebIn report still brings data that was in the infocube before, but no longer exists! The report should bring 0 register as the infocube is empty.
    It sounds to be a cache problem! I went to CMC >> Servers >> WebIn Server and unchecked the CACHE boxes, in order to bypass the data in cache but, it did not work.
    Does somebody has an ideia of what is going on??
    Thanks a lot.
    regards.

    Hi Alican!
    I actually built the report again, from scracth.
    I checked Universe and no errors came out.
    regards.

  • Why does the amber light stay on even though the WiFi works?

    My WIFi just stopped yesterday.
    Initially nothing worked. I then Restarted the router—then the Airport Extreme–NOTHING.  I called Apple support. He had me push the re-start button and a few other things.  I can now get on WIFi, but the amber light still stays on. Why? Although my Mac works great, my iPhone doesn't.
    Any ideas?

    I would recommend that you do the following as a minimum:
    Power-down the modem, AirPort base station, and computer(s).
    Power-up the modem; wait at least 10-15 minutes to allow it adequate time to initialize.
    Power-up the AirPort base station; wait at least 5-10 minutes. Note: The AirPort's status light may continue to flash amber after it has intialized. That is because, there may be some additional configuration items necessary, like setting up wireless security, before the overall setup is completed to get a green status.
    Power-up your computer(s).
    If the above steps do not solve the problem, start over with step 1 above, but then perform the next steps between steps 1 & 2. above.
    Disconnect the AirPort base station from the Internet broadband modem.
    While all of the devices are powered-down, perform a "factory default" reset on the base station. This will get it back to its "out-of-the-box" configuration and make setting it up much easier, especially if you use the "Assist me" process within the AirPort Utility. (ref:Resetting an AirPort Base Station or Time Capsule)
    After the base station resets, go ahead and power it back down.
    Reconnect the AirPort base station to the Internet broadband modem. For the Extreme and Time Capsule, be sure to connect the cable to the base station's WAN (circle-of-dots) port.
    Continue with step 2 in the first set of steps.
    In this basic configuration, the AirPort base station will broadcast an unsecured wireless network with a Network Name (SSID) of Apple Network NNNNNN. Network clients, connected to the base station either by wire or wireless, should now be able to access the Internet through the ISP's modem. Once Internet connectivity has been verified, you can use the AirPort Utility to configure the base station for wireless security and any other desired options. Please post back your results.

  • Getting an VISANS timeout error even though VISA Status is 0

    I have an application that runs well on my development system but consistently fails at the user site giving out timeout errors even though the user experiences no time outs. Indeed, VISA returns a success status. Yet, it raises timeout exceptions such as in this segment from my trace log:
    DefaultSource, Verbose, 8, Setting timeout to 30000, "CONNECT", 2008-08-12 00:47:21Z, 2077539389311920
    DefaultSource, Information, 0, GPIB0::26::INSTR termination character set to 10, "CONNECT", 2008-08-12 00:47:21Z, 2077539630487436
    DefaultSource, Verbose, 8, Checking GPIB0::26::INSTR message available, "FR, CONNECT", 2008-08-12 00:47:21Z, 2077539636730532
    DefaultSource, Verbose, 8, Flushing read GPIB0::26::INSTR buffer, "FR, CONNECT", 2008-08-12 00:47:21Z, 2077539673800216
    DefaultSource, Error, 2, Flushing read GPIB0::26::INSTR buffer failed: NationalInstruments.VisaNS.VisaException: Timeout expired before operation completed.  VISA error code -1073807339 (0xBFFF0015), ErrorTimeout
       at NationalInstruments.VisaNS.Internal.ErrorChecker.CheckStatusAndThrow(Int32 status, VisaHandle visaObject)
       at NationalInstruments.VisaNS.Session.CheckStatusAndThrow(Int32 status)
       at NationalInstruments.VisaNS.Session.BufferedReaderService.NationalInstruments.VisaNS.Internal.IBufferedReader.Scan(String scanSpecifier, Int32& count, StringBuilder receiver)
       at NationalInstruments.VisaNS.MessageBasedSessionReader.CommonReadString(String scanString, Int32 count)
       at NationalInstruments.VisaNS.MessageBasedSessionReader.ReadLine()
       at isr.Visa.MessageBasedReader.ReadLine()
       at isr.Visa.GpibSession.ReadLine()
       at isr.Visa.Ieee4882.Instrument.ReadString()
       at isr.Visa.Ieee4882.Instrument._flushRead(). VISA status=Success, "FR, CONNECT", 2008-08-12 00:47:21Z, 2077539717184364
    DefaultSource, Verbose, 8, Flushing GPIB0::26::INSTR write buffers, "FW, CONNECT", 2008-08-12 00:47:21Z, 2077539723797900
    DefaultSource, Verbose, 8, , "WRITE, FW, CONNECT", 2008-08-12 00:47:21Z, 2077539731761192
    DefaultSource, Error, 2, Flushing GPIB0::26::INSTR write buffers failed: NationalInstruments.VisaNS.VisaException: Timeout expired before operation completed.  VISA error code -1073807339 (0xBFFF0015), ErrorTimeout
       at NationalInstruments.VisaNS.Internal.ErrorChecker.CheckStatusAndThrow(Int32 status, VisaHandle visaObject)
       at NationalInstruments.VisaNS.Session.CheckStatusAndThrow(Int32 status)
       at NationalInstruments.VisaNS.Session.BufferedWriterService.NationalInstruments.VisaNS.Internal.IBufferedWriter.WriteLine()
       at NationalInstruments.VisaNS.MessageBasedSessionWriter.WriteLine()
       at isr.Visa.MessageBasedWriter.WriteLine(String queryCommand)
       at isr.Visa.GpibSession.WriteLine(String queryCommand)
       at isr.Visa.Ieee4882.Instrument.WriteLine(String value)
       at isr.Tsp.TspVisaIO.WriteLine(String value)
       at isr.Visa.Ieee4882.Instrument._flushWrite(). VISA status=Success, "WRITE, FW, CONNECT", 2008-08-12 00:47:21Z, 2077539742753448
    The first exception above is raised on the session Message Based Reader ReadLine() command.
    Note that I check for message available before issuing read. 
    Note also that VISA NS returns a status code of success:   VISA status=Success (this is what I log above)
    The second exception is raised after I try to clear the write buffers using the Message Based Writer command: WriteLine()
    Here too VISA reports success.
    Note also that the above segment executes in less than one second whereas the time out is set to 30 seconds. 
    The user runs VISA 4.3 runtime.  I am using NationaInstruments.VisaNS 8.1.20.222.
    I would be most grateful for some clues as to how to further explore this issue.  We have been at it for a few days already and are not seeing any light at the end of this tunnel.
    David

    Hello David,
    It looks like you are not passing any valid handlers in your viUninstallHandler command.  Calling viUninstallHandler removes the specified handler from the list of
    active handlers on the given session.  You can see the exact error information for your error in the picture below.
    Useful information can be found in the manual:  VISA Programmers Reference Manual Pages 5-146 & 7
    Have a great day!
    Meghan R
    Applications Engineer
    National Instruments
    Message Edited by Meghan R on 08-15-2008 11:39 AM
    Attachments:
    ScreenHunter_01 Aug. 15 11.33.gif ‏9 KB

  • After using my macbook for 2 years with same printer,all of a sudden I can't print a page doc even though printer is working and I can print from I/Mail, etc.Anybody had this happen and have a possible answer?

    After using my MacBook Pro and pages for 2 years with the same printer, all of a sudden I can't print a pages doc even though the printer works and I can print from I/Mail, etc. Anyone have a possible answer?

    Often printing problems are a sign of corrupt preferences. Go to HD > Users > (your account) > Library > Preferences, delete the com.apple.iwork.pages.plist file & then restart Pages.

  • I just updated my 3gs to the latest iOS 5 update and now I am unable to text certain numbers.  I keep getting the error code 1121611611 invalid number, even though the number I have in my contacts is a 10 digit number.  Any suggestions on fixing this?

    I just updated my 3gs to the latest iOS 5 update and now I am unable to text certain numbers.  I keep getting the error code 1121611611 invalid number, even though the number I have in my contacts is a 10 digit number.  Any suggestions on fixing this?

    PhotogYogi wrote:
    I Have the same issue on a brand new iPad mini 2. My battery is only lasting up to 5 hours. I went on chat with Apple last night and they said my battery is fine and its a Safari issue. I'm literally losing 1% every 3-4 minutes. I tried recalibrating my battery, signing out of iCloud, shutting off all locations, turning off background app refresh, restoring network settings, restoring all, and finally restoring from iTunes with no luck. This is just awful. I got this iPad so I could use it on my long flight for a trip I have coming up, and unfortunately, it's not going to last that long, plus I'm concerned about how many times i will be recharging my battery because of this since battery's do have a life cycle dependent on the number of charges. This is frustrating and needs to be fixed ASAP and addressed by Apple.
    By the way, Apple told me to bring my device to the Apple Store because it's still under warranty. That's great and all, but I'm going to waste my time if there is no fix for this issue.
    Ok so you want Apple to address the problem, but yet you don't want to take it to them just in case they can't fix it? What if they can fix it? Complaining here certainly won't fix it.

  • Syntax error in Se80 even though the syntax is right

    Hi ,
    We are using a three system landscape. DEV -
    TST---CON
    The correction request released from dev sytem has no syntax error in both DEV and TST but only in cons system.
    All systems hare in the same basis SP levels for release 620.
    Even though the sytax is absolutely correct and no activation errors.The program has sytax error during generation phase.
    Any ideas as to  why this is occuring and how can we rectify it.
    In the class attributes the type is unknow sytax error is thrown.
    TT_INFTYPES  Static     Protected     Type     TT_TYPES     
    below is the definition for TT_TYPES.
    begin of t_types,
        ity type inty,
      end of t_types,
      tt_types type standard table of t_types.
    The sysntax is correct but still I get syntax error only in cons system.
    Edited by: Vighneswaran CE on Nov 26, 2010 12:41 PM

    It would be helpful to know the exact syntax error message.
    So now i'm just guessing INTY doesn't exist on CON.

  • Hey guys, when i try and log in to itunes, even though the details are correct it is showing up as an error and not allowing me access to my account.. could anyone help??

    Hey guys, when i try and log in to itunes, even though the details are correct it is showing up as an error and not allowing me access to my account.. could anyone help?

    what is the error?

  • After upgrading to 3.6.8 none of the plugins load even though there are updates available. The updates will not install and even though the error states to look at the console error log there are no errors listed in the log.

    After upgrading to 3.6.8 none of the extensions load even though there are updates available. The updates will not install and even though the error states to look at the console error log there are no errors listed in the log. All extensions are listed in Addons>Extensions.
    == This happened ==
    Every time Firefox opened
    == Upgrading to newer Firefox version (3.6.8)

    I have been having the same issue for the last two weeks. No real indication as to why it ever began other than I had turned off my router and Airport Extreme Base Station off for a weekend while I was away from my place.
    iPad, iPhone, iPod Touch, all have no issues at all with my Airport Extreme Base Station. Can stay connected throughout my living room, bathroom, bedroom, no issues whatsoever.
    My 5 month old MacBook Pro 2.66 GHz Core i7 Airport is sometimes perfect, able to connect, DHCP, and browse without issue. Then, for no reason, I won't be able to join my wireless network, or when I can join, I can't pick up an IP address. And then it will connect, pick up and IP, and then it won't browse. No real rhyme or reason to when this will happen, or when it works.
    I thought that it was an issue with my MacBook Pro, but then my sister visited with her brand new MacBook Pro 2.26 Intel Core 2 Duo, and while a month ago she was able to connect, DHCP, and browse without issue, this weekend she had all of the same issues I was having.
    My XBOX 360 and MacBook Pro have absolutely no issues with the wired connection. Only my WAN seems to have this issue.
    Did you ever find anything more to this?

  • When following your instructions on setting a blank new tab, I get and error message "invalid url", even though the sting entered in the config is as you state.

    I would like a blank new tab to open, but have followed the help guidance to modify the about:config.
    However, for all strings shown, I get a consistent error message "invalid url", even though the string has been copied correctly.

    This issue can be caused by an extension that isn't working properly.
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Qa32-confirm the operation before proceeding error even though operation is confirmed.

    Hi,
    In qa32, while doing ud and while saving, it is showing the error message as confirm the operation before proceeding.even though the operations are confirmed. we are doing the co1f conformation.please find the screenshots for the issue.
    we are 3 in process inspections operations with operation nos 25,65,75. The 25,65 operations we are closing in qa32 with force closer. i.e when operation 75 doing ud, the inspection operations 25,65 happening force closer. But in order even though operations are confirming also,it is showing the below error message while doing ud in qa32. Please help me on this. why it is showing that error message even though operations are confirmed.
    Regards,
    Mastan.

    Memory errors have nothing to do with actual lack of RAM. The file is damaged or references a potentially critical external component like a specific printer driver whose info has been stored in the file, a font, a color profile, a linked image or whatever. You need to figure out those problems instead of blindly throwing more resources art the program. As a start, try to open the file on another system. If it works you can limit the investigation to the specific machine and even if it doesn't it may give you a more meaningful warning that helps to diagnose the error.
    Mylenium

Maybe you are looking for

  • *Possible* SOD / High Pitch Sound

    i know i posted this in another post as a reply allready but i though maybe other people could find this thread better this wayif any mods see this as a double post or what not delete the other one... it may not be a fix so im not gonna shout it out

  • Song goes in one playlist but not another

    I am in the process of using ITunes Match. Close to half my songs are in the icloud now. One of my newer  songs was recently matched, shows that it was matched,  and is supposedly now in icloud. I dragged that song into one of my ITunes playlists wit

  • ESS service Absence

    Hi expert. I have this problem. I have the rol SAP_EMPLOYEE_XX_ESS_WDA_1, in NWBC show the service absence, but I need know which is the service?. which  is The web dynpro component or application web dynpro? I need show this service in the portal(ja

  • Would like to choose Default as my Calendar; only option is Facebook

    I don't use e-mail on my Blackberry, and I usually don't have Facebook installed.  I have used the Blackberry for YEARS and have kept my BB calendar synched to my Outlook Calendar on my computer.  Then I installed Facebook, and then deleted the app. 

  • About writting in a file

    When overwritting to an existing file , what would happen it the existing file has a bigger size than the data written in it ? I haven't tried it right now , but i would know how this is done in Java . Thanks in advance for any valuable answer.