Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

novice windows programmer seeks advice

2 views
Skip to first unread message

Ravi Dronamraju

unread,
Mar 22, 2006, 6:32:25 PM3/22/06
to

Hi,

I have programmed most of my life in the windows env and now set out to
build an embedded windows app.

My accomplishment :
- I managed to compile mozilla tree on windows.

But now, i am kinda stuck. What do i do next?

- I can build and run mfcembed.exe by using "make" from cygwin
- I cannot load mfcembed project files in VS 2005 (corrupt dsp file)
- How do i use visual studio 2005 to build an embedding app?
- What kind of project within VS2005? I am guessing either mfc or CLR.
- Is it better to build a CLR windows forms app that embeds mozilla
or MFC?

alvin

unread,
Mar 22, 2006, 7:09:15 PM3/22/06
to
I am also in the same boat.. any help much appreciated.

Ravi Dronamraju

unread,
Mar 22, 2006, 7:34:53 PM3/22/06
to
Ravi Dronamraju wrote:
>
> Hi,
>
> I have programmed most of my life in the windows env and now set out to
^^^^^^^^^^^^^^^^^^
in the UNIX env. I *Never* programmed in the windows env

Help appreciated :)

Niky Williams

unread,
Mar 23, 2006, 8:13:26 AM3/23/06
to Ravi Dronamraju

Ravi,

Well, you have two ways to go about it really. You can use the Mozilla
Active X from John Lock...or you can implement the interfaces yourself.
The Active X control doesn't send back all the events, so really its
best for just displaying web pages...not reacting to events like clicks
and key presses (unless it's been updated recently). I choose to
implement the interfaces myself, it takes a bit longer to get it setup,
but you have more control over it. Which one are you going to use? In
either case...below are some instructions that I've put together over
the few times I've had to setup my environment for embedding Gecko (Win
2K & VS 2003). I'm not sure exactly how far along you are (I see you
were able to make from cygwin the mfcembed.exe) so I'll start from the
beginning, hope this helps!!

NOTE*** I've only tried this with the 1.0.7 code, not 1.5 yet.

--You've probably done all the way to step 12.
1) Download and unzip the mozilla source code
2) Download Cygwin (http://www.cygwin.com) and run...install the
following packages
a) 'make' under the 'Devel' category
b) 'perl' under 'Interpreters' category
c) 'unzip' under 'Archive' category
d) 'zip' under 'Archive' category
3) Download Netscape's wintools.zip from
http://ftp.mozilla.org/pub/mozilla.org/mozilla/source/wintools.zip and
put that in a 'Tools' directory...or some other name you want to use.
Unzip there.
a) Run the install.bat file under the "buildtools\windows" directory
4) Next, go to
ftp://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32/ and
download the glib and libIDL version 7.1 (I THINK it's the same for VS
2005) and extract to the same dir as you did your wintools.zip file
5) Now you have to setup your environment variables for the user (right
click on "My Computer" -> Properties, Advanced tab, Environment
Variables button)
GLIB = <where ever you unzipped glib>\vc71
LIBIDL = <where ever you unzipped libIDL>\vc71
MOZ_TOOLS = <where ever you unzipped wintools>\windows
PATH = %GLIB%\bin;%LIBIDL%\bin;%MOZ_TOOLS%\bin
HOME = <Where ever the base dir of your project resides> //This is for
CYGWIN so it knows what it's home directory is
//Optional
XPCOM_DEBUG_BREAK = warn
6) Create yourself a ".mozconfig" file...easiest way I've found to do it
is do a "copy con" command in the cmd window just to create the
file...once created, open with notepad and edit. Windows doesn't like
to create names that start with a period in the explorer.
7) Mozilla.org has some good tools on creating a .mozconfig file...here
is the one I use to make a browser...very simple

#-----------------------------------------------------------------
# For building firefox, this needs to be included
. $topsrcdir/browser/config/mozconfig

# Options for client.mk.
mk_add_options MOZ_CO_PROJECT=browser

# Options for 'configure' (same as command-line options).
ac_add_options --enable-application=browser
ac_add_options --enable-crypto
#-----------------------------------------------------------------

8) Make a shortcut to vsvars32.bat created by the VS.Net app, this will
setup some things for building
9) Rename the link.exe in your Cygwin/bin to something else...like
link.exe.old
10) run the vsvars32.bat, browse to where you installed Cygwin and run
the Cygwin.bat file.
11) Once it's up and running, navigate to the mozilla dir (where you
unzipped the mozilla code) and run "./configure"
12) Once that is done, run "make -f client.mk build" to start the
building process.

Now to setup the VS environment to build...I use straight Win32, so I
create a blank project when I start this.
After you have your blank project setup, do the following:
Directories the project needs to know where to search for include files:
\mozilla\dist\include\layout
\mozilla\dist\include\dom
\mozilla\dist\include\uriloader
\mozilla\dist\include\profdirserviceprovider
\mozilla\dist\include\string
\mozilla\dist\include\necko
\mozilla\dist\include\gfx
\mozilla\dist\include\docshell
\mozilla\dist\include\widget
\mozilla\dist\include\webbrwsr
\mozilla\dist\include\windowwatcher
\mozilla\dist\include\embed_base
\mozilla\dist\include\nspr
\mozilla\dist\include\xpcom

These libraries also need to be linked to your app
xpcom.lib
embed_base_s.lib
nspr4.lib
profdirserviceprovider_s.lib

Also add \mozilla\dist\lib to the list of directories it looks in for
libraries for the project

Also add \mozilla\dist\bin to your PATH environment variable so it will
know where to find xpcom.dll, etc...

Tell the linker to ignore LIBCD.lib (Debug mode)/LIBC.lib (Release mode)

Whew...okay, I think thats it. My notes are a little old so they may be
a little quirky but that is the basic steps of what I do to get my
environment setup for embedding gecko. Good Luck!!

Niky Williams

??

unread,
Mar 23, 2006, 12:49:55 PM3/23/06
to
Maybe you can read the source code of uBrowser.

http://www.ubrowser.com/index.php

--
"???? ????"
"Ravi Dronamraju" <ra...@dronamraju.com> ???
news:3cKdnSDdJOURQ7zZ...@mozilla.org ???...

alvin

unread,
Mar 26, 2006, 12:53:05 AM3/26/06
to
Hi Niky,

Thanks for the instructions - has helped alot.

I am just at the point where I can nearly build my own test application
- but am getting some linking errors. It seems that it cannot find the
proper dll's (xpcom.dll etc.)

I followed your instructions and done the following -
- built mozilla
- setup my VS environment to include the appropriate headers. (Proj.
Properties->C/C++ -> General->Additional Include Directives
- added libraries to be linked to the app (Proj.
Properties->Linker->Input->Additional Dependancies)
- added \mozilla\dist\bin to my path
- Told linker to ignore LIBCD.lib/LIBC.lib (Proj.
Properties->Linker->Input->Ignore Specific Libraries)

In addition I have done the following to make my application compile -
- Added the preprocessor tag MOZILLA_INTERNAL_API (Proj.
Properties->C/C++ -> Preprocessor->Preprocessor Definitions)
- Changed runtime library to MT (Proj. Properties->C/C++ ->Code
Generation->Runtime Library)
- Changed buffer security check to no (Proj. Properties->C/C++ ->Code
Generation->Buffer Security Check)
- Change so it is not using precompiled headers (Proj. Properties->C/C++
->Precompiled Headers->Create/Use Precompiled Header)
- Told linker to ignore MSVCRT.lib (Proj.
Properties->Linker->Input->Ignore Specific Libraries)

Below is a snippet of the linking errors I am getting (I think problem
with linking to xpcom.dll) -

Linking...
winEmbed.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: void __thiscall
nsCOMPtr_base::assign_from_helper(class nsCOMPtr_helper const &,struct
nsID const &)"
(__imp_?assign_from_helper@nsCOMPtr_base@@QAEXABVnsCOMPtr_helper@@ABUnsID@@@Z)
..
..
C:\Documents and Settings\alvins\My Documents\Visual Studio
2005\Projects\TestEmbed\Release\winEmbed.exe : fatal error LNK1120: 12
unresolved externals


Thanks again for your help.

Alvin

> .. $topsrcdir/browser/config/mozconfig

alvin

unread,
Mar 26, 2006, 1:03:12 AM3/26/06
to
Sorry forgot to mention -
- added \mozilla\dist\bin to my path (this was done by going to
Start->Control Panel->System->Advanced->Environment Variables)

> ...

Ravi Dronamraju

unread,
Mar 27, 2006, 12:36:41 AM3/27/06
to
niky,

thanks from my side as well for all the help. I think i am making
progress :)

alvin, can you share a copy of your test embedding program? I am trying
chop code off the mfcembed and it's probably more complex than i need.

-ravi

Niky Williams

unread,
Mar 27, 2006, 8:03:59 AM3/27/06
to alvin

Alvin,
I left Code Generation on Sigle Thread for mine...not sure if this will
make a difference, also I didn't have to define the preprocessor
MOZILLA_INTERNAL_API. I do remember fiddling with single/multiple
thread at one point...but I can't remember why. I looks like you have
everything pointing correctly so it can find everything okay...are you
building with 1.5 or 1.0.x? I tried building with 1.5 at one point, but
it needed some additional libs linked with the project...I didn't have
time to fiddle with it, so I stayed with 1.0.x since I needed something
up pretty quickly. Off the top of my head, I don't have any suggestions
. If I think of something, I'll reply back.

Niky Williams

Ravi Dronamraju

unread,
Mar 27, 2006, 6:40:26 PM3/27/06
to
I tried niky's instructions and went forward. Here's what i observed

1) xpcom.dll is not under dist/lib but under dist/bin
2) If i used that xpcom.dll to compile it fails with this error
"c:\mozilla\dist\bin\xpcom.dll : fatal error LNK1107: invalid or corrupt
file: cannot read at 0x2B8"

Has anyone seen this before?
-ravi

alvin

unread,
Mar 28, 2006, 2:06:47 AM3/28/06
to Ravi Dronamraju
Hi Ravi,

I was under the impression (i'm not an expert in this) that when you add
dist\bin to your PATH variable that Visual Studio knows where to get it
from when you build.

Alvin

alvin

unread,
Mar 28, 2006, 2:13:40 AM3/28/06
to Niky.W...@ntsmarketing.com
Hi Niky,

Thanks for the response.

I am using the latest source from cvs - if I can't get it working I a
might try drop back to 1.5.

I don't have the option of using Single Thread.. all options are Multi.
It is interesting to note that if I change to MD it gives me a different
error - but I don't think this has anything to do with it.

Alvin


Niky Williams wrote:
> Alvin,
> I left Code Generation on Sigle Thread for mine...not sure if this will
> make a difference, also I didn't have to define the preprocessor
> MOZILLA_INTERNAL_API. I do remember fiddling with single/multiple
> thread at one point...but I can't remember why. I looks like you have
> everything pointing correctly so it can find everything okay...are you
> building with 1.5 or 1.0.x? I tried building with 1.5 at one point, but
> it needed some additional libs linked with the project...I didn't have
> time to fiddle with it, so I stayed with 1.0.x since I needed something
> up pretty quickly. Off the top of my head, I don't have any suggestions

> .. If I think of something, I'll reply back.
>
> Niky Williams

Benjamin Smedberg

unread,
Mar 28, 2006, 4:32:49 AM3/28/06
to
Ravi Dronamraju wrote:
> I tried niky's instructions and went forward. Here's what i observed
>
> 1) xpcom.dll is not under dist/lib but under dist/bin
> 2) If i used that xpcom.dll to compile it fails with this error
> "c:\mozilla\dist\bin\xpcom.dll : fatal error LNK1107: invalid or corrupt
> file: cannot read at 0x2B8"

You cannot link against DLLs on Windows, you have to link against the
matching import library xpcom.lib.

--BDS

Niky Williams

unread,
Mar 28, 2006, 10:29:32 AM3/28/06
to Benjamin Smedberg

Yes, BDS is correct...is why dist/lib is used instead of dist/bin.

Niky Williams

Ravi Dronamraju

unread,
Mar 28, 2006, 9:08:35 PM3/28/06
to

thanks for the advice, one more hurdle crossed and now i am falling
forward at another one.

I discovered that I am required have a derived class from
nsIDirectoryServiceProvider to do ns_InitEmbedding. I created that
class. Now, It seems that i cannot create a CString and cast it to
nsCString. Is there a trick to it?

error C2440: '<function-style-cast>' : cannot convert from 'wchar_t *'
to 'nsCString_external'

-ravi

Niky Williams

unread,
Mar 29, 2006, 7:58:22 AM3/29/06
to Ravi Dronamraju
Try something like this:

//Converts UTF16 to UTF8
char *pSomePointer = (char*) NS_ConvertUTF16toUTF8 (sValue).get ();

//Converts UTF8 to UTF16
sValue.Assign (NS_ConvertUTF8toUTF16 (szSomeString));

I'm not sure if there is a "better" way of doing it, but it seems to
work fine for me, Good Luck!

Niky Williams

alvin

unread,
Mar 30, 2006, 7:11:09 AM3/30/06
to Niky.W...@ntsmarketing.com
Ok I have made some progress. After reading some of the other posts
about dlls/libs - i decided to add all the libs. i.e. Proj.
Properties->Linker->Input->Additional Dependancies

I am left with just 4 unresolved dependencies which I can't seem to get
rid of. Do I have to link to any other libraries other than what's in
the lib folder?

Maybe someone can point out which lib the following functions reside in
(looks to me like xpcom or one of its associated libs).

Linking...

winEmbed.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: void __thiscall
nsCOMPtr_base::assign_from_helper(class nsCOMPtr_helper const &,struct
nsID const &)"
(__imp_?assign_from_helper@nsCOMPtr_base@@QAEXABVnsCOMPtr_helper@@ABUnsID@@@Z)

winEmbed.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: void __thiscall

nsCOMPtr_base::assign_from_qi_with_error(class nsQueryInterfaceWithError

const &,struct nsID const &)"

(__imp_?assign_from_qi_with_error@nsCOMPtr_base@@QAEXABVnsQueryInterfaceWithError@@ABUnsID@@@Z)

winEmbed.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: void __thiscall

nsCOMPtr_base::assign_with_AddRef(class nsISupports *)"
(__imp_?assign_with_AddRef@nsCOMPtr_base@@QAEXPAVnsISupports@@@Z)

winEmbed.obj : error LNK2001: unresolved external symbol

"__declspec(dllimport) public: static wchar_t const * const
nsCharTraits<wchar_t>::sEmptyBuffer"
(__imp_?sEmptyBuffer@?$nsCharTraits@_W@@2PB_WB)

C:\Documents and Settings\alvins\My Documents\Visual Studio

2005\Projects\TestEmbed\Release\winEmbed.exe : fatal error LNK1120: 4
unresolved externals

Alvin

Niky Williams

unread,
Mar 30, 2006, 8:33:45 AM3/30/06
to

The only libs I have found with those references are xpcom.lib and
embed_base_s.lib that I can see. Maybe someone else has some other info
on this?

Niky Williams

0 new messages