Skip to content

V9.12 Fix the lnk1189 problem #4596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: stable
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ message(STATUS "${PROJECT_NAME} version: ${PROJECT_VERSION}")

if(MSVC)
set(CMAKE_CXX_STANDARD 20)
# 设置源代码和执行字符集为 UTF-8(MSVC 2015 及以上支持 /utf-8)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use english in comment
why MSVC 2015 ? we only support 2022...

message(STATE "set utf-8=======")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no STATE and this log seems a debug log/dev to suppress imho

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry,this is my fault

add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
# message(STATE "set bigobj=======")
add_compile_options(/bigobj)
SET(CMAKE_CXX_FLAGS_DEBUG "/Od2")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ? I prefer to be conservative and keep the cmake default debug configuration

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My releas compilation caused errors in lnk1189, and I found two solutions on the Internet, so I added both of them. The compilation time was too long, so I added both solutions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@Mizux Mizux Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC we already enable /bigobj...

or-tools/cmake/cpp.cmake

Lines 102 to 105 in 35c27ab

# Compiler options
if(MSVC)
list(APPEND OR_TOOLS_COMPILE_OPTIONS
"/bigobj" # Allow big object

target_compile_options(${PROJECT_NAME} PUBLIC ${OR_TOOLS_COMPILE_OPTIONS})


# 设置堆栈保留大小为16MB(单位:字节)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:104857600")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /STACK:104857600")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please explain

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set the stack retention size.

else()
set(CMAKE_CXX_STANDARD 17)
endif()
Expand Down Expand Up @@ -443,22 +454,22 @@ include(dotnet)

# Since samples mix all languages we must parse them once we have included all
# <language>.cmake files
foreach(SAMPLES IN ITEMS
algorithms
graph
glop
constraint_solver
linear_solver
${MATH_OPT_DIR}
${PDLP_DIR}
sat)
add_subdirectory(ortools/${SAMPLES}/samples)
endforeach()
# foreach(SAMPLES IN ITEMS
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this (and below) ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it was my fault. I forgot to remove the comment. Very Very Sorry.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it was my fault. I forgot to remove the comment. Very Very Sorry.

# algorithms
# graph
# glop
# constraint_solver
# linear_solver
# ${MATH_OPT_DIR}
# ${PDLP_DIR}
# sat)
# add_subdirectory(ortools/${SAMPLES}/samples)
# endforeach()

# Same for examples
foreach(EXAMPLES IN ITEMS contrib cpp dotnet java python)
add_subdirectory(examples/${EXAMPLES})
endforeach()
# foreach(EXAMPLES IN ITEMS contrib cpp dotnet java python)
# add_subdirectory(examples/${EXAMPLES})
# endforeach()

# Add tests in examples/tests
add_subdirectory(examples/tests)
# add_subdirectory(examples/tests)