24

I'm working on a new solution configuration for our large VC++ project using VS 2008. I'd like this configuration to use the multicore build flag /MP.

However, the "#import" feature of generating COM wrapper classes is sprinkled through-out the code base and this feature is not supported when using /MP.

I understand why #import won't work, I want to know if anyone has faced this issue and how they worked around it?

I am doing the following:

  • Not use the /MP flag on projects that are small or beyond help. (maybe I'll come back to them later)
  • Removed the #import and replaced it with a more standard MIDL-generated header (#include). This is only an option in a few places that are easy to convert to old school COM.
  • Make a new project that #imports the remaining libraries. Make that build first. #Include the .tlh files it creates in all the places that #imported previously.

I'm curious if anyone has any other suggestions? Also, on the last point (making a new project and using #import only there) - if you did something like this, how did you do it? What type of project, what did the "source" look like, where did you output files? How did you include them? (you know, do all the thinking for me!)

3
  • 1
    your last option seems like the best way to go about it if you want multicore builds - it is consistent and no wasted work. Sorr that I can't help with details about it,
    – Tim
    Oct 31, 2008 at 20:45
  • Thanks for the comment. Turns out I'll need several stages of tlh generation at different stages of the build (a near hopeless battle). I've put this on hold - my current battle is to move off of VSS.
    – Aardvark
    Nov 3, 2008 at 0:33
  • 4
    Here is your answer stackoverflow.com/questions/650578/… Nov 4, 2011 at 12:03

2 Answers 2

12

I have a project with two source files which #import the same file. When compiling with /MP, it would occasionally get an access denied error since both source files were trying to create the .tlb at the same time. I correct this by enabling pre-compiled headers, and adding the #import into the pre-compiled header source file.

1
  • 1
    This worked for me. Not sure if there are any downsides, but for now I'm happy. Thanks.
    – criddell
    Jul 12, 2010 at 15:56
9

You can use the /MP option for the project as a whole, and then make an exception for a single file using the /MP1 option.

1
  • 3
    In VS 2017, just turned off the /MP for the file(s) that contain #imports
    – Brett
    Apr 28, 2019 at 18:15

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.