CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  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,635

    Re: unresolved externals??

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

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  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
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured