[RESOLVED] unresolved externals??
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: [RESOLVED] unresolved externals??

Hybrid View

  1. #1
    Join Date
    Apr 2013
    Posts
    34

    [RESOLVED] unresolved externals??

    ok, I've gotten this problem before, but usually when I erase everything, and completely re-write it it works. but I don't feel like doing that again, I want to know why it's not working (and I have another program I made exactly like this one that works perfectly.. and I've been trying to copy it, but I can't find any more differences (other then variable names and such)

    I've googled this problem before and came up empty handed, it looks like the problem occurs when a function is declared but not used.. but to me it looks like it is used... here is the code (simplified for easier diagnosis)

    Main.cpp:
    Code:
    #include <Windows.h>
    #include <iostream>
    #include "Headr.h"
    
    using namespace std;
    
    
    
    int main()
    {
    
    	int e = 12;
    	int r = 12; 
    	int ret;
    	
    	ret=sendint(e,r);
    	cout << ret ;
    	cin.get();
    
            return 0;
    }
    second.cpp:
    Code:
    #include <Windows.h>
    #include <iostream>
    #include "Headr.h"
    
    using namespace std;
    
    
    int sendint(int x,int y)
    {
    	cout << x << y;
    	return 0;
    }
    Headr.h
    Code:
    int sendint(int x,int y);

    any Idea's? thanks, I owe you guys a lot already

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,206

    Re: unresolved externals??

    Which external is unresolved? Post the exact message. Why are you including Windows.h?

  3. #3
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,755

    Re: unresolved externals??

    On my system using MSVS the code you have posted compiles and links cleanly with no errors and produces the correct output when run. If this code is giving you a linker(?) error then it must be how the solution/project has been setup. Has second.cpp been added to the project properly? When you build the solution does it say that it's compiling main.cpp and second.cpp? In the solution explorer, under Source Files you should see both main.cpp and second.cpp listed.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  4. #4
    Join Date
    Apr 2013
    Posts
    34

    Re: unresolved externals??

    wow.. >.< apparently I had made the second "cpp" file, as a header file instead, fixed that, runs perfect now... jeeze, I hate when you waste and hour or two when stuff like that happens >.< thank you guys, now I feel silly

    thanks again!

  5. #5
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,755

    Re: unresolved externals??

    Quote Originally Posted by peteandperry View Post
    I hate when you waste and hour or two when stuff like that happens >.< thank you guys, now I feel silly

    thanks again!
    These things happen to the best of us! Don't tell anyone - but I once spent several hours trying to find a problem in a program - it turned out I was debugging the wrong set of code.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center