Groups | Blog | Home
all groups > visual studio .net ide > september 2006 >

visual studio .net ide : [VS 2005] Custom Build Step problem in C++


Michael Russell
9/19/2006 11:20:11 AM
Hi all,

Sorry for the repost, but I never received any response when I first
asked this a few weeks ago. I would really appreciate some feedback on
this, it's driving me nuts...

I'm beginning the process of moving some projects from VS.Net 7 to
VS2005. I'm having problems getting a Custom Build Step to work.

In the dialog for the header file I want to perform the custom step on,
I copy and paste the command line:
$(QTDIR)\bin\moc.exe "..\Messenger.h" -o ".\moc_Messenger.cpp"

I also set description, outputs, additional dependencies
($(QTDIR)\bin\moc.exe), and click Ok. I can open the dialog up again,
and see all the options as I set them.

However, when I do a build, it fails, with moc.exe complaining of
invalid arguments. When I check the Command Line entry in the Custom
Build Step properties again, it now contains:
$(QTDIR)\bin\moc.exe -DQT_NO_DEBUG -D_WINDOWS -DUNICODE -DWIN32
-DQT_DLL -DQT_THREAD_SUPPORT -I"$(QTDIR)\include" -I"."
-I"d:\Qt\3.3.2\mkspecs\win32-msvc.net" "..\Messenger.h" -o
".\moc_Messenger.cpp".

I can remove the '-DQT_NO_DEBUG -D_WINDOWS -DUNICODE -DWIN32 -DQT_DLL
-DQT_THREAD_SUPPORT -I"$(QTDIR)\include" -I"."
-I"d:\Qt\3.3.2\mkspecs\win32-msvc.net', compile, get the error, repeat
ad naseum.

Is there some option somewhere in VS2005 that is causing it to add the
defines and includes to the command line for a CBS? I never experienced
this in VS 7.

Carl Daniel [VC++ MVP]
9/20/2006 8:50:03 AM
[quoted text, click to view]

I'm not aware of any switch - but I suspect that the problem lies in the
fact that .h is an extenion that the IDE recognizes, so it's "helping" you.
Would it be possible to use a different extension for this file - one that
the IDE doesn't know anything about?

You might want to look into the features in VC2005 that allow you to define
your own build tools (based on file extension) so you don't have to worry
about writing custom build steps. Finding the options in the help is rather
torturous, but...


In the solution explorer, right-click on your C++ project and choose "Custom
Build Rules..." from the context menu.
On the dialog that appears, click "New Rule File...".
Give your new rule file a name, like "Run MOC"

.... and so on. It's a bit more involved than one might hope (but it's also
pretty powerful). See

http://msdn2.microsoft.com/en-us/library/03t8bzzy.aspx

as a starting point.

-cd

AddThis Social Bookmark Button