Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7641345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:53:55+00:00 2026-05-31T08:53:55+00:00

I am using CreateProcess to invoke cl to compile and link another C++ program

  • 0

I am using CreateProcess to invoke cl to compile and link another C++ program (TestProg.cxx) into a DLL. I invoke cl.exe with the following compilation options:

compilation options:

/Od /nologo /Fo /RTC /w /Zc TestProg.cxx /DLL

the call:

if ( CreateProcess(PATH_TO_EXE, COMPILATION_OPTIONS, NULL,NULL,
                   FALSE,0,NULL,NULL,&si,&pi) ) 
{
    //....
}

If TestProg.exe contains #include <iostream.h> I got the following compilation error:

TestProg.cpp(1) : fatal error C1034: iostream.h: no include path set

Without any #include command, I got the following linkage error:

LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib'

What am I doing wrong?

I searched the answer for the last 6-7 hours on the web, but didn’t find it. Using windows API is new to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:53:56+00:00Added an answer on May 31, 2026 at 8:53 am

    If you look at the definition of CreateProcess:

    BOOL WINAPI CreateProcess(
      __in_opt     LPCTSTR lpApplicationName,
      __inout_opt  LPTSTR lpCommandLine,
      __in_opt     LPSECURITY_ATTRIBUTES lpProcessAttributes,
      __in_opt     LPSECURITY_ATTRIBUTES lpThreadAttributes,
      __in         BOOL bInheritHandles,
      __in         DWORD dwCreationFlags,
      __in_opt     LPVOID lpEnvironment,
      __in_opt     LPCTSTR lpCurrentDirectory,
      __in         LPSTARTUPINFO lpStartupInfo,
      __out        LPPROCESS_INFORMATION lpProcessInformation
    );
    

    You’re setting the optional parameter __in_opt LPVOID lpEnvironment, to NULL.

    According to said definition:

    A pointer to the environment block for the new process. If this parameter is NULL, the new process uses the environment of the calling process.

    cl.exe gets its include location information and library search paths from environment variables – have a look at setenv.bat in the VS directory. In this case, neither your calling process or your target process are running in an environment where these variables are set.

    You have a choice – you can create the environment variables yourself according to the MSDN:

    An environment block consists of a null-terminated block of
    null-terminated strings. Each string is in the following form:

    name=value\0
    

    Because the equal sign is used as a separator, it must not be used in
    the name of an environment variable.

    Or you can require your program to be run from the VS tools prompt. A good check this is actually the problem would be to run your program from this prompt, rather than Visual Studio, to see if that fixes the issue.

    The reason not using #include produces a linker error is due to the fact if there are no includes, cl.exe won’t look for them – it then looks for the C/C++ runtime libs.

    As a side note – I believe the standard in C++ is to #include <iostream> i.e without the .h.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using CreateProcess to invoke cl and link to compile and link another
I am trying to create a program that calls another process using CreateProcess. After
I have written a program a.exe which launches another program I wrote, b.exe ,
I'm using PyWin32's win32process.CreateProcess to start up a GUI program that has functionality I
My Windows XP/7 program launches a child process using the Windows API CreateProcess() function
I launch the following command line (process) from a Windows VC++ 6 program using
I am using CreateProcess to create a cmd.exe process that is passed a parameter
I am using CreateProcess function for creating the process, is there any option to
I'm executing an external application using the CreateProcess function, in order which such application
Using LINQ on collections, what is the difference between the following lines of code?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.