|
My app works with mysql db and only lib's I'm linking are: libmysql.lib, mysys.lib and strings.lib. And trough my code I have
#pragma comment(lib, "Netapi32.lib")
#pragma comment(lib, "mpr.lib")
#pragma comment(lib, "shlwapi.lib") This is an simple sdi app created with vs2008. Sure I have some CMFC controls (like toolbars and so) which are from feature pack. I didn't try to install re-distributable file on target machines.
modified on Tuesday, March 23, 2010 8:28 AM added additional libs from my code
|
|
|
|
|
to link staticly is one solution. For that you need the static libs of mysys.lib etc.
or you build a setup which will include the dlls which you will need. Test it on virtual machines.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
With Release version errors are:
1>FileVersion.obj : error LNK2001: unresolved external symbol __pgmptr
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
|
|
|
|
|
There are both MFC runtime libraries and the C++ runtime library.
The linker error messages appear to relate to the runtime library, not MFC. They look to me like the libs referenced expect the runtime library to be dynamically linked. At least some of them appear to be specific to debugging, which would explain why your later post indicates that these errors go away in your release build.
Note that there are problems if a DLL and and exe are linked to different versions of the runtime library and one tries to release dynamic memory allocated by the other.
josip cagalj wrote: I didn't try to install re-distributable file on target machines.
Any dependencies of your program need to be included in your installation. The target machine may or may not have the appropriate versions of the MFC and runtime library dlls installed. This depends on the Windows version. It can also be impacted by service packs and other software installed on that machine.
josip cagalj wrote: 1>With Release version errors are:
1>FileVersion.obj : error LNK2001: unresolved external symbol __pgmptr
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv
1>nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc
This sounds like an issue with the start-up code. Perhaps some sort of confusion between whether you are producing a console app or a GUI app?
Please do not read this signature.
|
|
|
|
|
Thanks for contributing, my app is SDI MFC.
One question just to make my self clear, when I use 'Project > Properties > Linker > Input > Additional Dependencies' entering libmysql.lib mysys.lib strings.lib is this dynamically linking or static. Same question for
#pragma comment(lib, "Netapi32.lib")
#pragma comment(lib, "mpr.lib")
#pragma comment(lib, "shlwapi.lib") entries.
When compiled will exe contain those lib's or do I need to make sure that those lib's exist on target machine by building msi file?
My gold is to have the exe which will contain all necessary stuff to work on win target machine (Win2000, XP, Vista, Win7).
|
|
|
|
|
Hi. my program has ANSI multibyte compilated and uses several Unicode data sources. To convert Unicode to multibyte I use the folowing code:
WideCharToMultiByte(CP_ACP,WC_NO_BEST_FIT_CHARS,sUnic,numb_chars,ansi_buf,numb_chars,NULL,NULL);
This conversion works very fine in All code pages, but on Chinese systems dont works correctly - several characters from end of source unicode string is not converted. Please make happy our chinese clients! Thanks.
|
|
|
|
|
You are using the value numb_chars for the length of both buffers, but that may not be the case. You should use the following sequence to ensure you have enough space for the multibyte string:
int nMBChars;
nMBChars = WideCharToMultiByte(CP_ACP,WC_NO_BEST_FIT_CHARS,sUnic,numb_chars,NULL,0,NULL,NULL);
PTSTR ansi_buf = new TCHAR[nMBChars + 1];
int nMBConv = WideCharToMultiByte(CP_ACP,WC_NO_BEST_FIT_CHARS,sUnic,numb_chars,ansi_buf,nMBChars,NULL,NULL);
See here[^] for full details.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Thanks, Richard! You example code works fine!
|
|
|
|
|
Hi All
I m trying to develop MDI Application in explorer view.
Left side contains a tree view
Right side contains a dialog that will be open when a user clicks on a value in tree view.
Can Anyone provide a tutorial on this ...
Regards
Gany
|
|
|
|
|
That sounds more like a splitter than MDI. If you are using MFC then the CSplitterWnd[^] class should help you. Take a look at the articles here on CodeProject for potential samples.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
|
Hi
Thanks for the info.
But is tutorial is any available to start with ???
consider me as a begineer.
Regards
Gany
|
|
|
|
|
Hi
Any ways to help me>?
Regards
Gany
|
|
|
|
|
I am unsure If I am using my #include directives correctly and where to define my structures.
I have many files that are project independent, a .c and .h and when I want the features I have written in my main.c I #include feature.h as normal. What I wonder is I declare all of the includes that feature needs in its header and sometimes I have another include of the same file in another feature.h as well as my main.c
I know that the compiler is invoked for every separate c file so it will include say function _delay() in every .c file. The linker then puts all the objects together and makes the binary but does it strip the duplicate _delays?? I know the pragma once and other inclusion guards are only relative to that source file being compiled and each source will include the functions.
Along the same lines I have a enum states{Info = 0, Speed = 1}; declared in my header and want to use these states in multiple source files so I include the header when I need it. I also have an initialized structure struct branch the_table[8][5] = { {Control,0,0,0,0,0}, {Speed,0,0,0,0,0} }; and since this structure is using memory I must put it in my source file the problem is I want to be able to access this array outside of its source file and if I declare extern truct branch the_table[8][5]; in the header with the rest of the structure decelerations other source files cannot access its internal structure.
Can someone give some insight onto multiple inclusions upon linking and how to properly declare previously defined structures?
|
|
|
|
|
Trevor Johansen wrote: I know that the compiler is invoked for every separate c file so it will include say function _delay() in every .c file. The linker then puts all the objects together and makes the binary but does it strip the duplicate _delays?? I know the pragma once and other inclusion guards are only relative to that source file being compiled and each source will include the functions.
There is no need to strip the duplicates because there aren't actually duplicate functions (you may include the function declaration in all C source files, provided the function definition -i.e. the function body- is in just one source file).
Trevor Johansen wrote: declared in my header and want to use these states in multiple source files so I include the header when I need it. I also have an initialized structure struct branch the_table[8][5] = { {Control,0,0,0,0,0}, {Speed,0,0,0,0,0} }; and since this structure is using memory I must put it in my source file the problem is I want to be able to access this array outside of its source file and if I declare extern truct branch the_table[8][5]; in the header with the rest of the structure decelerations other source files cannot access its internal structure.
That's the correct way to do it: define the structure in one source file and made it available to other source files using the extern declaration.
As far as you use the #pragma once (do GCC recognize it?) directive (or the oldie-goldie #ifndef ...) to avoid multiple inclusions, I see no problem in your approach.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Ahh I see so my delay.c is compiled to its own object obviously so at link time file1.o and file2.o while both using _delay() get it from delay.o I could have figured that one out if I took the though process a bit deeper eh..
This extern setup is a pain in the butt. I have multiple structures in my files for example I have my menu system as:
enum states {
Info = 0,
Speed = 1,
Up = 2,
Down = 3,
Control = 4,
OnOff = 5,
CW = 6,
CCW = 7
};
struct branch {
enum states new_state:7;
int entry_action;
int action_a;
int action_b;
int action_c;
int exit_action;
};
These are in my header file and almost exclusive to that source file except as the project grew I now need to read branch data from a separate source file. In that file if I include the header I get multiple definition errors of struct branch. Moving that structure to the source and declaring extern struct branch; solves the error but now I cannot use the structure in other source files as it says its undefined.
|
|
|
|
|
If you define the struct variable in one source file and declare it extern in another one, then such variable is avalable in the latter (and the linker won't complain), for instance:
(common header)
struct Point
{
int x,y;
};
void init();
(first source)
#include "main.h"
Point centre={0,0};
void init()
{
centre.x=100;
centre.y=120;
}
(second source)
#include <iostream>
#include "main.h"
extern Point centre;
void out()
{
std::cout << "cente = {" << centre.x << ", " << centre.y << "}" << std::endl;
}
void main()
{
init();
out();
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for the help. I was defining correctly but the way I was handling the data was what was causing me problems as well. All fixed now.
Another question though, are #define's project global? I would love to know if I can say write an LCD library and use my own defines and macros but not have them conflict with the users program. I seem to not be able to and thats why we are told to append the file/function name before the name.
I just didn't really want 50 defines prefixed with LCD_
|
|
|
|
|
#define is resolved by the preprocessor, before the compiler starts hence they are global (for all sources including the corrensponding header).
You may go the C++ way: use const or (enum ) for your constants and wrap them in a namespace.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I hope this question is not too basic for this forum but I have been working at this for a while now and need to get something working.
I would like to be able to place a bitmap in my IE window when predetermined web pages are accessed, detect mouse clicks etc in IE and have IE function normally for all other pages.
I program in C/C++ and already have an intermediate level of familiarity with visual studio 2005 and mfc and have looked into BHOs, COM, ATL and ActiveX and find myself a bit overwhelmed.
If someone could just lay out a road map for me of the essentials so that I know what study path to follow to get to the point where I can build the above add on I would greatly appreciate it. Please point me to any existing apps that you know of that may help as well.
Thanks in advance for any help.
|
|
|
|
|
|
Hi-
I have been trying to work out how to delete a single point from a quad tree and am having no luck at all. Below are the code snippets for delete the entire tree then my failed attempt at deleting a single point. If someone could explain what I am doing wrong I would appreciate it.
Deleting the entire tree:
qnode *
deleteTree (qnode * root)
{
int i = 0;
for (i = 0; i < 4; i++)
{
if (root == NULL)
return root;
if (root->children[i] != NULL)
{
free (root->children[i]);
deleteTree (root->children[i]);
if (root->leaf == TRUE)
{
free (root);
root->leaf = NULL;
}
root->children[i] = NULL;
root->leaf;
root->cx = NULL;
root->cy = NULL;
root->size = NULL;
}
}
}
Failed attempt to delete a single point:
qnode *
deleteP (qnode * root, int vx, int vy)
{
int i = 0;
if (root->px - 5 >= vx && vx <= root->px + 5 && root->py - 5 >= vy && vy <= root->py + 5)
{
if (root == NULL)
return root;
if (root->leaf == TRUE)
{
root->leaf = NULL;
free (root);
}
else
{
root->leaf = TRUE;
deleteP (root, vx, vy);
root->px = NULL;
root->py = NULL;
free (root);
}
}
}
Thank you for your time
|
|
|
|
|
First, you have bugs in your deleteTree implementation.
Chidori-chan wrote:
free (root->children[i]);
deleteTree (root->children[i]);
This is undefined behavior. Once you have freed the child node, it is no longer yours and you must not access it. Reverse the order of these two lines.
There are more problems in your deleteTree implementation as well. I will let you work on finding them.
Perhaps I am wrong here, but I would think that deleting a single point actually means deleting the entire subtree starting from that point. Otherwise, what do you do about all those would be orphaned nodes? So I expected to see a call to deleteTree somewhere in deleteP. I didn't find it.
Also, I would think that you need to traverse the tree to locate the point to be deleted. I would expect that to be the first thing you would have to deal with, but don't see it in your code.
Please do not read this signature.
|
|
|
|
|
Without fully understanding the code above I noticed a couple of things in the deleteTree() function:
if (root->leaf == TRUE)
{
free (root);
root->leaf = NULL;
}
You then continue using the root pointer.
The following statement is meaningless.
root->leaf;
In the following block in the deleteP() function:
if (root->leaf == TRUE)
{
root->leaf = NULL;
free (root);
}
there is no point in setting root->leaf to null, as you immediately free the object. Similarly in the else block you set two pointers to null immediately before freeing the object.
Also both functions have paths that do not return values, and thus should not compile.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Thank you all for your help, keeping your advice in mind I have come up with these functions and it kinda works. It will delete points only in a certain area of the screen..
int checkKids(qnode *parent)
{
int i;
for(i = 0; i < 4; ++i)
if(parent->children[i] != NULL)
return 0;
return 1;
}
void deletE(qnode *root)
{
if(checkKids(root) && !root->leaf)
{
root = NULL;
free(root);
}
else
{
int i;
for(i = 0; i < 4; ++i)
if(root->children[i] != NULL)
deletE(root->children[i]);
}
}
void deletePoint()
{
deletE(root);
}
void deletePointS (int sx, int sy, qnode *root)
{
int i;
for(i=0; i<4; i++)
{
if(root->children[i] != NULL)
{
if(root->children[i]->leaf == TRUE)
{
if(isIn(root->children[i]->px, root->children[i]->py, sx, sy, 5))
{
root->children[i] = NULL;
free(root->children[i]);
if(checkKids(root))
{
free(root);
root = NULL;
}
return;
}
}
else
{
deletePointS(sx, sy, root->children[i]);
}
}
}
}
void deleteNode (int sx, int sy)
{
int deleting;
if(deleting == 1)
return;
deleting = 1;
deletePointS(sx, sy, root);
deletePoint();
deleting = 0;
}
|
|
|
|
|