Skip to content
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

Build libslic3r as dll or Visual Studio project #5039

Closed
AndreasReitberger opened this issue Oct 31, 2020 · 7 comments
Closed

Build libslic3r as dll or Visual Studio project #5039

AndreasReitberger opened this issue Oct 31, 2020 · 7 comments

Comments

@AndreasReitberger
Copy link

Offtopic, not an issue

I'm trying to build a dll out of the slicer library, however I don't get it done using cmake.
It always says it cannot find "PrecompiledHeaders".
Has anybody made a dll out if the lib? Or better a Visual Studio project?

...src\libslic3r

It would be awesome if anybody could share the created Visual Studio project here.
Thanks!

@foreachthing
Copy link

@AndreasReitberger
Copy link
Author

This has always been my reference:

https://github.com/prusa3d/PrusaSlicer/blob/master/doc/How%20to%20build%20-%20Windows.md#noob-guide-step-by-step

Yes, this was the first thing I've tried.. however I always get an error that the "PrecompiledHeaders" cannot be found.

@foreachthing
Copy link

foreachthing commented Oct 31, 2020

I've made this batch file and this works like a charm.
This batch assumes VS2019.
EDIT: you might need to run it in "Developer PowerShell for VS2019".

@echo off

ECHO I'm going to CLONE the PrusaSlicer repository - ready?
ECHO Best, if you're curently in c:\dev (or similar short path)
ECHO Also make sure you got at least 15 GB of free disk space available
ECHO.
ECHO Press CTRL+BREAK if you want to cancel.
PAUSE
ECHO Are you sure??? Shall I continue?
PAUSE

git clone https://github.com/prusa3d/PrusaSlicer.git --recursive
cd PrusaSlicer

SET "thisPATH=%CD%"
echo Building in %thisPATH%

cd deps
mkdir build
cd build

cmake .. -G "Visual Studio 16 2019" -DDESTDIR="%thisPATH%"

REM This will take a loooong time! Go get some coffee...
msbuild /m ALL_BUILD.vcxproj

cd "%thisPATH%"
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -DCMAKE_PREFIX_PATH="%thisPATH%\usr\local" -Wno-dev -Wno-error=deprecated

msbuild -ds -nologo PrusaSlicer.sln -t:rebuild -m -p:Configuration=Release -verbosity:normal

REM Robocopy to the release dir:
REM Make sure this destination dir exists.
rem robocopy "c:\dev\PrusaSlicer\build\src\Release" "c:\PrusaSlicer-Release" /MIR /xf *.exp *.lib *.pdb /R:600 /W:30

You'll need to compile it yourself. This directory requires ~12 GB, so I can't really share it ...

@foreachthing
Copy link

Then, if I want to rebuild PS, I just start this PowerShell-Script (in c:\dev\PrusaSlicer\):

$gitstat=git pull --verbose
$gitcommit=git rev-parse HEAD
$done=0

function RebuildPrusaSlicer {
    cd build
    msbuild -ds -nologo PrusaSlicer.sln -t:rebuild -m -p:Configuration=Release -verbosity:normal
    cd ..
}

function SyncRelease {
    Write-Output "====== Mirror to PrusaSlicer-Release ======"
    robocopy "c:\dev\PrusaSlicer\build\src\Release" "c:\PrusaSlicer-Release" /MIR /xf *.exp *.lib *.pdb /R:600 /W:30
}

If (($gitstat -join '') -eq ('Already up to date.')) { 
    Write-Output ""
    Write-Output "### Already up to date."
    Write-Output ""
        
    $confirmation = Read-Host "Do you want to copy the current build anyway?" `
        "(y/n) Or do you want to force rebuild and sync? (R)"
    if ($confirmation -eq 'y') {
        SyncRelease
        $done=1
    }	
    Elseif ($confirmation -eq 'R') {
        RebuildPrusaSlicer	
        SyncRelease
        $done=1
    } else {
        $done=0
    }

} Else { 

    Write-Output ""
    Write-Output "====== Rebuilding now. This will take some time! ======"
    
    Start-Sleep -s 2

    RebuildPrusaSlicer
    
    SyncRelease
    
    $done=1

}

if ($done -eq 1){
    Write-Output ""
    Write-Output $("Commit now at : " + $gitcommit.SubString(0,7))	
    Write-Output ""
} else {
    Write-Output ""
    Write-Output "Build and sync aborted"	
    Write-Output ""
}

Good luck!

@AndreasReitberger
Copy link
Author

@foreachthing
Awesome! Your script is working fine on my end. Thanks for sharing!

@foreachthing
Copy link

@AndreasReitberger, I'm glad I could help.
Now ... do you know what you might have done different from my script? Basically, my script does what the "noob guide" says. I'd like to know, because if the "noob guide" was unclear, I might consider a PR on the guide and add my script to it.

@AndreasReitberger
Copy link
Author

Hi @foreachthing
actually the guide is fine. First the batch wasn't working either. I had to re-install cmake manually. Then it started to work with your batch. Guess there were some problems.
Thanks for helping out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants