Discussion:
V8 MFC App
Jon Hardcastle
2008-01-18 13:04:34 UTC
Permalink
Hello,

I am very new to scons, and have been tasked with
trying to get it to compile our app after i initially
identified it as plausible.

I am stuggling though. I know our app depends on a
number of home grown libs, so i have cut back to one
in partcular that uses no other home grown libs just
an mfc app compiled in V8.

I am really struggling.

I got as far as

StaticLibrary('cbwbBase.lib', workbenchapp.cpp')

I even put all the inclue and lib dir's that VS uses
and that are defined globally.. but it always falls
over on

workbenchapp.cpp(570) : error C3861: 'AfxLoadLibrary':
identifier not found
scons: *** [workbenchapp.obj] Error 2
scons: building terminated because of errors.

Can anyone help me?

Thank you!!!

-----------------------
N: Jon Hardcastle
E: ***@eHardcastle.com
'The writing is on the wall...'
-----------------------
David Cournapeau
2008-01-18 13:22:49 UTC
Permalink
Post by Jon Hardcastle
Hello,
I am very new to scons, and have been tasked with
trying to get it to compile our app after i initially
identified it as plausible.
I am stuggling though. I know our app depends on a
number of home grown libs, so i have cut back to one
in partcular that uses no other home grown libs just
an mfc app compiled in V8.
I am really struggling.
I got as far as
StaticLibrary('cbwbBase.lib', workbenchapp.cpp')
I even put all the inclue and lib dir's that VS uses
and that are defined globally.. but it always falls
over on
identifier not found
scons: *** [workbenchapp.obj] Error 2
scons: building terminated because of errors.
Can anyone help me?
Without more details, it will be hard to help you. First, although this
has nothing to do with your problem, do not put the .lib in the name of
the target: scons will add it automatically.

Now, concerning the error: I know nothing about MFC, but if
AfxLoadLibrary is a function, maybe the header where the function is
declared is not included ? Typically, you may have to define some CPP
variables to get it included ?

cheers,

David
Jon Hardcastle
2008-01-18 14:22:43 UTC
Permalink
Post by Jon Hardcastle
Post by Jon Hardcastle
Hello,
I am very new to scons, and have been tasked with
trying to get it to compile our app after i
initially
Post by Jon Hardcastle
identified it as plausible.
I am stuggling though. I know our app depends on a
number of home grown libs, so i have cut back to
one
Post by Jon Hardcastle
in partcular that uses no other home grown libs
just
Post by Jon Hardcastle
an mfc app compiled in V8.
I am really struggling.
I got as far as
StaticLibrary('cbwbBase.lib', workbenchapp.cpp')
I even put all the inclue and lib dir's that VS
uses
Post by Jon Hardcastle
and that are defined globally.. but it always
falls
Post by Jon Hardcastle
over on
identifier not found
scons: *** [workbenchapp.obj] Error 2
scons: building terminated because of errors.
Can anyone help me?
Without more details, it will be hard to help you.
First, although this
has nothing to do with your problem, do not put the
.lib in the name of
the target: scons will add it automatically.
Now, concerning the error: I know nothing about MFC,
but if
AfxLoadLibrary is a function, maybe the header where
the function is
declared is not included ? Typically, you may have
to define some CPP
variables to get it included ?
cheers,
David
Thanks,

I know that according to the help docs

'Using AfxLoadLibrary in an application requires you
to dynamically link to the DLL version of MFC'

Visual Studio somehow magically doing that.. but i
don't know how to express that in scons.. what i have
currently...

(you can see i am trying to 'use' mfc by libs = mfc80)


env = Environment(CPPDEFINES='/D"SquashArgs"')

env.StaticLibrary('cbwbBase', 'workbenchapp.cpp',
CPPPATH = [
'C:\Program Files\Microsoft Visual Studio
8\VC\atlmfc\include'
'C:\Program Files\Microsoft Visual Studio
8\VC\include'
'C:\Program Files\Microsoft Visual Studio
8\VC\PlatformSDK\Include'
'C:\Program Files\Rogue Wave\Stingray Studio
2006\Include',
'C:\Program Files\Rogue Wave\Stingray Studio
2006\Regex\Include',
'C:\Program Files\Rogue Wave\Stingray Studio
2006\RWUXTheme\Include',
'C:\Program Files\Spread60\Include',
'C:\Dev8\PenCalc',
'C:\Dev8\PenCalc\Legislation',
'C:\Dev8\cbwbBase',
'C:\Dev8\DesignTime\WorkBenchPrinting',
'C:\Dev8\cbwbBase\DotNetConvert',
'C:\Dev8\DesignTime',
'..\Pencalc',
'..\Pencalc\Legislation',
'..\DesignTime\WorkBenchPrinting',
'..\DesignTime'],
LIBS = ['PenCal32', 'mfc80'],
LIBPATH = [
'C:\Program Files\Microsoft Visual Studio 8\VC\lib'
'C:\Program Files\Microsoft Visual Studio
8\VC\atlmfc\lib'
'C:\Program Files\Microsoft Visual Studio
8\VC\PlatformSDK\Lib'
'C:\program Files\rogue Wave\stingray Studio 2006',
'C:\Program Files\Rogue Wave\Stingray Studio
2006\Lib',
'C:\Program Files\Rogue Wave\Stingray Studio
2006\Regex\Lib\VC6',
'C:\Dev8\DesignTime',
'C:\Program Files\Microsoft Visual
Studio\VC98\mfc\lib',
'C:\Program Files\Microsoft Visual Studio\VC98\lib',
'C:\Program Files\Microsoft Platform SDK for Windows
Server 2003 R2\Lib',
'C:\Program Files\Rogue Wave\Stingray Studio
2006\Lib',
'C:\Program Files\Rogue Wave\Stingray Studio
2006\Lib\Themes8c',
'..\PenCalc\Debug'])

-----------------------
N: Jon Hardcastle
E: ***@eHardcastle.com
'The writing is on the wall...'
-----------------------
David Cournapeau
2008-01-18 14:20:00 UTC
Permalink
Post by Jon Hardcastle
Thanks,
I know that according to the help docs
'Using AfxLoadLibrary in an application requires you
to dynamically link to the DLL version of MFC'
Visual Studio somehow magically doing that..
There is a reason why some people do not like IDE :) More seriously,
there is no way around it: you will have to know what those magic
incantations are.
Post by Jon Hardcastle
but i
don't know how to express that in scons.. what i have
currently...
I can't help you to know the incantations (other familiar with win32 may
be more helpful, but keep in mind that those problems are not strictly
scons' ones), but if you give us the command used to compile the project
under VS, it will be easier.

cheers,

David
Jon Hardcastle
2008-01-18 14:34:10 UTC
Permalink
Post by David Cournapeau
Post by Jon Hardcastle
Thanks,
I know that according to the help docs
'Using AfxLoadLibrary in an application requires
you
Post by Jon Hardcastle
to dynamically link to the DLL version of MFC'
Visual Studio somehow magically doing that..
There is a reason why some people do not like IDE :)
More seriously,
there is no way around it: you will have to know
what those magic
incantations are.
Post by Jon Hardcastle
but i
don't know how to express that in scons.. what i
have
Post by Jon Hardcastle
currently...
I can't help you to know the incantations (other
familiar with win32 may
be more helpful, but keep in mind that those
problems are not strictly
scons' ones), but if you give us the command used to
compile the project
under VS, it will be easier.
cheers,
David
Thanks..

The command used in the build log is..
/Od /I "..\Pencalc" /I "..\Pencalc\Legislation" /I
"..\DesignTime\WorkBenchPrinting" /I "..\DesignTime"
/D "_DEBUG" /D "CBWB_RT" /D "SquashArgs" /D "_AFXDLL"
/FD /EHsc /MDd /GR- /Yc"stdafx.h"
/Fp"Debug\cbwbBase.pch" /Fo"Debug\\"
/Fd"Debug\vc80.pdb" /W3 /c /Zi /Gz /TP
.\ADOConnection.cpp

with a list of files after that..

don't know if this would help?

i think the problem is scons isn't using the mfc stuff..

-----------------------
N: Jon Hardcastle
E: ***@eHardcastle.com
'The writing is on the wall...'
-----------------------
Gary Oberbrunner
2008-01-18 14:39:20 UTC
Permalink
Post by Jon Hardcastle
The command used in the build log is..
/Od /I "..\Pencalc" /I "..\Pencalc\Legislation" /I
"..\DesignTime\WorkBenchPrinting" /I "..\DesignTime"
/D "_DEBUG" /D "CBWB_RT" /D "SquashArgs" /D "_AFXDLL"
^^^^^^^^^^^^^
Oh yeah, there's the smoking gun right there. Add all those /D's to your
CPPDEFINES (CPPDEFINES=['_DEBUG', 'CBWB_RT', 'SquashArgs', '_AFXDLL']) and
you'll be golden.
--
Gary Oberbrunner
Jon Hardcastle
2008-01-18 14:45:22 UTC
Permalink
Thank you.. I was marching down that road already but
was doing this

# env = Environment(CPPDEFINES=['/D"SquashArgs" /Od /I
"..\Pencalc" /I "..\Pencalc\Legislation" /I
"..\DesignTime\WorkBenchPrinting" /I "..\DesignTime"
/D "_DEBUG" /D "CBWB_RT" /D "_AFXDLL" /FD /EHsc /MDd
/GR- /Yc"stdafx.h" /Fp"Debug\cbwbBase.pch" /Fo"Debug"
/Fd"Debug\vc80.pdb" /W3 /nologo /c /Zi /Gz /TP'])

taken wholesale from VS..

now I have this..

env = Environment(CPPDEFINES=['_DEBUG', 'CBWB_RT',
'SquashArgs', '_AFXDLL'])

But can you tell me where I put switches for the
compiler?

it now says..

C:\Program Files\Microsoft Visual Studio
8\VC\atlmfc\include\afxver_.h(77) : fatal error C1189:
#error : Please use the /MD switch for _AFXDLL builds

how do i correctly tell scons to pass /MD?
Post by Jon Hardcastle
Post by Jon Hardcastle
The command used in the build log is..
/Od /I "..\Pencalc" /I "..\Pencalc\Legislation" /I
"..\DesignTime\WorkBenchPrinting" /I
"..\DesignTime"
Post by Jon Hardcastle
/D "_DEBUG" /D "CBWB_RT" /D "SquashArgs" /D
"_AFXDLL"
^^^^^^^^^^^^^
Oh yeah, there's the smoking gun right there. Add
all those /D's to your
CPPDEFINES (CPPDEFINES=['_DEBUG', 'CBWB_RT',
'SquashArgs', '_AFXDLL']) and
you'll be golden.
--
Gary Oberbrunner
---------------------------------------------------------------------
-----------------------
N: Jon Hardcastle
E: ***@eHardcastle.com
'The writing is on the wall...'
-----------------------
Gary Oberbrunner
2008-01-18 14:49:12 UTC
Permalink
Post by Jon Hardcastle
But can you tell me where I put switches for the
compiler?
it now says..
C:\Program Files\Microsoft Visual Studio
#error : Please use the /MD switch for _AFXDLL builds
how do i correctly tell scons to pass /MD?
Those go in CCFLAGS: CCFLAGS=['/MD', '/DEBUG'] etc.
--
Gary Oberbrunner
Jon Hardcastle
2008-01-18 14:51:05 UTC
Permalink
Thank you vmuch, I have just sussed that one :)

For some reason scons has started beeping after every
obj compiled, any reason for this?

It wasn't doing it yesterday! maybe I added a flag
accidentally?

Cheers!
Post by Jon Hardcastle
Post by Jon Hardcastle
But can you tell me where I put switches for the
compiler?
it now says..
C:\Program Files\Microsoft Visual Studio
8\VC\atlmfc\include\afxver_.h(77) : fatal error
#error : Please use the /MD switch for _AFXDLL
builds
Post by Jon Hardcastle
how do i correctly tell scons to pass /MD?
Those go in CCFLAGS: CCFLAGS=['/MD', '/DEBUG'] etc.
--
Gary Oberbrunner
---------------------------------------------------------------------
-----------------------
N: Jon Hardcastle
E: ***@eHardcastle.com
'The writing is on the wall...'
-----------------------
Gary Oberbrunner
2008-01-18 15:24:27 UTC
Permalink
Post by Jon Hardcastle
Thank you vmuch, I have just sussed that one :)
For some reason scons has started beeping after every
obj compiled, any reason for this?
It wasn't doing it yesterday! maybe I added a flag
accidentally?
/nologo?
--
Gary Oberbrunner
Jon Hardcastle
2008-01-18 16:29:54 UTC
Permalink
Hey quick effciency question that i can't seem to get
a clear answer to from the doc's

if i am building a load of .cpp files for a lib or exe
or whatever.. and i pass the list in like..

env.Program('cbwb', Split("""
aparamvl.cpp
ARITHMET.cpp
ArithmeticRow.cpp
AutoColour.cpp
AutoColourDemoSpread.cpp
autosave.cpp
breakpts.cpp
canimtry.cpp.... blah

will that try and compile them concurrently? Or
perhaps i should call Object? and then stitch the objs
with Program..?
Post by Gary Oberbrunner
Post by Jon Hardcastle
Thank you vmuch, I have just sussed that one :)
For some reason scons has started beeping after
every
Post by Jon Hardcastle
obj compiled, any reason for this?
It wasn't doing it yesterday! maybe I added a flag
accidentally?
/nologo?
--
Gary Oberbrunner
---------------------------------------------------------------------
-----------------------
N: Jon Hardcastle
E: ***@eHardcastle.com
'The writing is on the wall...'
-----------------------
Gary Oberbrunner
2008-01-18 18:31:11 UTC
Permalink
Post by Jon Hardcastle
Hey quick effciency question that i can't seem to get
a clear answer to from the doc's
if i am building a load of .cpp files for a lib or exe
or whatever.. and i pass the list in like..
env.Program('cbwb', Split("""
aparamvl.cpp
ARITHMET.cpp
...
Post by Jon Hardcastle
canimtry.cpp.... blah
will that try and compile them concurrently? Or
perhaps i should call Object? and then stitch the objs
with Program..?
It's exactly the same as calling Object on each one and then using Program on
the objects. There's been discussion of compiling them concurrently, but no
implementation of that optimization yet.
--
Gary Oberbrunner
Florian Sauer
2008-01-18 19:06:48 UTC
Permalink
Wouldn't that just require to do -j 20?
Post by Gary Oberbrunner
Post by Jon Hardcastle
Hey quick effciency question that i can't seem to get
a clear answer to from the doc's
if i am building a load of .cpp files for a lib or exe
or whatever.. and i pass the list in like..
env.Program('cbwb', Split("""
aparamvl.cpp
ARITHMET.cpp
...
Post by Jon Hardcastle
canimtry.cpp.... blah
will that try and compile them concurrently? Or
perhaps i should call Object? and then stitch the objs
with Program..?
It's exactly the same as calling Object on each one and then using Program on
the objects. There's been discussion of compiling them concurrently, but no
implementation of that optimization yet.
--
Gary Oberbrunner
---------------------------------------------------------------------
Gary Oberbrunner
2008-01-18 19:16:03 UTC
Permalink
Post by Florian Sauer
Wouldn't that just require to do -j 20?
Running 20 instances of a compiler, one on each object, is often quite
different than compiling a bunch of sources together into a single binary.
The compiler can optimize reading of include files, can keep the objects in
memory rather than writing them out to files, and so on. And of course
there's less startup overhead (only one compiler startup), memory, and context
switch overhead.
--
Gary Oberbrunner
Florian Sauer
2008-01-18 22:02:44 UTC
Permalink
Of course that is different. :) I am just not sure if that is what he is
after.
Post by Gary Oberbrunner
Post by Florian Sauer
Wouldn't that just require to do -j 20?
Running 20 instances of a compiler, one on each object, is often quite
different than compiling a bunch of sources together into a single binary.
The compiler can optimize reading of include files, can keep the objects in
memory rather than writing them out to files, and so on. And of course
there's less startup overhead (only one compiler startup), memory, and context
switch overhead.
--
Gary Oberbrunner
---------------------------------------------------------------------
Jon Hardcastle
2008-01-21 14:16:46 UTC
Permalink
Hey,

Thanks to all those that helped with my MFC problem on
Friday.

I am now trying to build the app that depended on the
one i built Friday.

It is failing with the following error:

CBWB.CPP : fatal error LNK1107: invalid or corrupt
file: cannot read at 0x168CB
scons: building terminated because of errors.

I look at the command line and i notice that there are
CPP extentioned files in with the OBJ's is that
normal?

EG (this is a scons built list)

link ...

autosave.obj breakpts.obj canimtry.obj CBWB.CPP
CBWBDOC.CPP cbwbfindinmapslist.obj

...

thanks again!

-----------------------
N: Jon Hardcastle
E: ***@eHardcastle.com
'The writing is on the wall...'
-----------------------
Jon Hardcastle
2008-01-21 14:38:34 UTC
Permalink
Post by Jon Hardcastle
Hey,
Thanks to all those that helped with my MFC problem
on
Friday.
I am now trying to build the app that depended on
the
one i built Friday.
CBWB.CPP : fatal error LNK1107: invalid or corrupt
file: cannot read at 0x168CB
scons: building terminated because of errors.
I look at the command line and i notice that there
are
CPP extentioned files in with the OBJ's is that
normal?
EG (this is a scons built list)
link ...
autosave.obj breakpts.obj canimtry.obj CBWB.CPP
CBWBDOC.CPP cbwbfindinmapslist.obj
...
thanks again!
This is because scons wasn't recognising the CPP as
cpp files that needed compiling and was just passing
the option over wholesale to be linked.

Not sure if this is classable as a 'bug' or not....

-----------------------
N: Jon Hardcastle
E: ***@eHardcastle.com
'The writing is on the wall...'
-----------------------

David Cournapeau
2008-01-18 14:42:36 UTC
Permalink
Post by Jon Hardcastle
Thank you.. I was marching down that road already but
was doing this
# env = Environment(CPPDEFINES=['/D"SquashArgs" /Od /I
"..\Pencalc" /I "..\Pencalc\Legislation" /I
"..\DesignTime\WorkBenchPrinting" /I "..\DesignTime"
/D "_DEBUG" /D "CBWB_RT" /D "_AFXDLL" /FD /EHsc /MDd
/GR- /Yc"stdafx.h" /Fp"Debug\cbwbBase.pch" /Fo"Debug"
/Fd"Debug\vc80.pdb" /W3 /nologo /c /Zi /Gz /TP'])
taken wholesale from VS..
now I have this..
env = Environment(CPPDEFINES=['_DEBUG', 'CBWB_RT',
'SquashArgs', '_AFXDLL'])
But can you tell me where I put switches for the
compiler?
it now says..
C:\Program Files\Microsoft Visual Studio
#error : Please use the /MD switch for _AFXDLL builds
how do i correctly tell scons to pass /MD?
switch is just another name for CFLAGS (for C sources). You will have to
add this one in CFLAGS variable.

Generally, think that scons is a cross platform system, and as such,
concepts likely to exist with other compilers/platforms have a cross
plaftorm solution in scons (do not use /D, but use CPPDEFINE, do not put
header path in CPPDEFINE, but use CPPPATH variable, put library
prefix/suffix in the target names, etc...).

Even if you do not intend to use another compiler, it will make the
sconscripts easier to maintain, by separating all the different kind of
compilation options.

cheers,

David
Gary Oberbrunner
2008-01-18 14:37:51 UTC
Permalink
Post by David Cournapeau
Post by Jon Hardcastle
Visual Studio somehow magically doing that..
There is a reason why some people do not like IDE :) More seriously,
there is no way around it: you will have to know what those magic
incantations are.
Post by Jon Hardcastle
but i
don't know how to express that in scons.. what i have
currently...
I can't help you to know the incantations (other familiar with win32 may
be more helpful, but keep in mind that those problems are not strictly
scons' ones), but if you give us the command used to compile the project
under VS, it will be easier.
David's right, it's not strictly a scons issue; any IDE-replacement will have
the same issues. But since I've done this a lot perhaps I can help.

I start by grepping around to find the header file that defines
AfxLoadLibrary. See if there are #ifdefs around it, and try to get those
ifdefs defined (via cmd-line -D, which is done in scons via CPPDEFINES) or
directly in your source file, before including windows.h or whatever.

On my machine AfxLoadLibrary is defined in /Program Files/Microsoft Visual
Studio .NET 2003/Vc7/atlmfc/include/afxdll_.h, which is included by afxwin.h
only if _AFXDLL is defined. So find out why _AFXDLL isn't defined, which will
lead you to your next clue, and so on.
--
Gary Oberbrunner
Loading...