|
What function (or method) is returning an error code to you and what is the error code?
Dan
|
|
|
|
|
I am trying to do this:
char szHostName[MAX_PATH];
gethostname(szHostName, MAX_PATH);
I have included winsock2.h yet am getting:
error LNK2019: unresolved external symbol __imp__gethostname@8
Anybody know what I am missing? VS2002
thanks, -mutty
|
|
|
|
|
Sounds like you are not linking with the Winsock2 library (Ws2_32.lib ).
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
thank you - how do I link WS2_32.lib?
Stupid - never mind this. I was trying to open the property pages for the SOLUTION, not the Project. No wonder there was no linker folder!
-mutty
-- modified at 13:42 Tuesday 14th February, 2006
|
|
|
|
|
Mutty wrote: thank you - how do I link WS2_32.lib?
#pragma comment(lib,"WS2_32.lib")
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Mutty wrote: I have included winsock2.h yet am getting:
error LNK2019: unresolved external symbol __imp__gethostname@8
Linker errors and header files (usually) have nothing to do with each other. Had it been a header-related issue, you would have most likely seen a compiler error.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
I've tryed the following code.
// somefile.h
class MyClass {
public:
inline void MemberFunction( void );
};
// somefile.cpp
#include "somefile.h"
void MyClass::MemberFunction( void ) // Also tryed "inline void MyClass::Memb..."
{
// Blá, blá, blá...
}
// Launcher.cpp
#include "somefile.h"
int main( void )
{
MyClass Example;
Example.MemberFunction();
return 0;
}
#ENDCODE
But I get
launcher.obj : error LNK2001: unresolved external symbol "public: void __thiscall CCPU::SomeFunction(void)" (?SomeFunction@CCPU@@QAEXXZ)
Debug/LOAC.exe : fatal error LNK1120: 1 unresolved externals
Any suggestions?
regards
hint_54
|
|
|
|
|
|
Yes, the file is part of the project and functions are the same (my mistake on that one )
regards
hint_54
|
|
|
|
|
The error is complaining about member SomeFunction() in class CCPU , but you show code from MyClass ...?
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
It was an example. I'm having this problem on several classes/member functions, so I decided to pull off the error message with a "SomeFunction()" function and post an example with sample names.
regards
hint_54
|
|
|
|
|
Only if you are sure that the code sample you posted is also generating the error...
Is the class' CPP file included in the project? Do things work correctly if you put the implementation of the function into the .H file?
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
James R. Twine wrote: Only if you are sure that the code sample you posted is also generating the error...
Yes, it is.
James R. Twine wrote: Is the class' CPP file included in the project?
Yes, it is.
James R. Twine wrote: Do things work correctly if you put the implementation of the function into the .H file?
Actually, they do. Even with the "inline" keyword. But if I don't use "inline" it works well in different files.
regards
hint_54
|
|
|
|
|
OK - something about inline functions needing to have their implementation be in the .H file comes to mind (after the class dec.), but I cannot find anything about it in the MSDN collection. I remember that this was a bug in VC++ 6.0 or something like that?
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
James R. Twine wrote: I remember that this was a bug in VC++ 6.0 or something like that?
Well, Could be... I'm using VC++ 6
regards
hint_54
|
|
|
|
|
Inline functions are not visible outside of the source file where they are defined. This is why you seem then declared in the same file, usually at the bottom, in which they are defined.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Like templates, right? I see.
Thx
hint_54
|
|
|
|
|
I'm looking for a good book to re-learn programming (in C++). I have Stroustrup but I have the feeling this will be more useful to me once I'm comfortable again. I've been away from programming for at least 4 years and only really learned "on the job" (tools programming windows dialog based apps), but would like to build a more solid foundation this time. I also have Eckels book but again this doesn't seem to be the kind of thing I'm after (though it's excellent on its own merits). I just wondered if there was a good "one book" answer to getting me started with the basics, including setting up compiling and linking properly (and understanding it!), and then building knowledge of the language and libraries etc in a structured, easy to follow way.
thanks in advance.
|
|
|
|
|
ldsdbomber wrote:
I'm looking for a good book to re-learn programming (in C++).
Since you asked a C++ question in a VC++ forum, which is it that you are ultimately after?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
You are in rare form today!
DavidCrow wrote: Since you asked a C++ question in a VC++ forum, which is it that you are ultimately after?
Other than the C++/CLI forum wouldn't this be the place?
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
By no means was I trying to be argumentative. I just didn't want to suggest Kruglinksi's "Inside Visual C++" book to him and then get a "But that's for Visual C++. I want to learn C++ first." response. Seeing as how he already has Stroustrup's book, I wasn't too sure of which route he wanted to take.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Sorry, I just spotted the VC++ forum and posted here, perhaps the other forum was the better one.
Anyway, as I mentioned originally, I want a Stroustrup style book but one that's more of a handheld walkthrough of C++ in a structured way. I had one or two but I can't remember the name of them - maybe Konig, or Shildt? That kind of thing, but I was also hoping that someone would have a good recommendation that will teach me thoroughly but also be fairly accessible.
|
|
|
|
|
Books are one of those things that are highly opinionated. You can ask a dozen people what their favorite is and you'll get 12 different answers. Everyone dis/likes a book for a different reason. I started programming in C and C++ with the help of Schildt and Petzold. Some folks shy away from those authors for various reasons. If you have a book in mind, check out amazon.com for customer reviews.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
LINK : warning LNK4089: all references to "SHELL32.dll" discarded by /OPT:REF
I keep getting this but don't know where to fix it. A search on google seemed to suggest I just need to take this out of project settings but i can't find it at all, I assume on the Link tab?
Any ideas?
|
|
|
|
|
This is not a problem. This is telling you that even though you are linking with the import library for SHELL32, you are not actually using any thing from the SHELL32 DLL (either by not explicitly calling something from the DLL, or code that did optimized out).
The result of this is that even though you linked with that DLL's import library, the executable will not require implicit (load-time) loading of that DLL.
Remove SHELL32.lib from your libraries, that should resolve the warning.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
-- modified at 12:17 Tuesday 14th February, 2006
|
|
|
|