Jump to content

How to Compile NifSkope 2.0dev7 on Linux


Foxroe

Recommended Posts

Compiling NifSkope 2.0dev7 on Linux
========================================

I've been trying on and off now for some time to compile this essential modding utility natively on Linux. It's my understanding that it compiles just fine on the major distro's like Ubuntu, Fedora, etc., but I don't use these distro's for various reasons. I'm a GNU/Linux masochist, so I run with Slackware (currently 15.0).

Well, I finally noodled it out, and I wanted to share the knowledge somewhere (the NifTools forums appear to be dead) in hopes that it will help the one other person in the world who is trying to compile NifSkope on Slackware (or another Linux flavor), and who doesn't want to run the Windows version of NifSkope through Wine.

So here goes nothing...

==== Requirements ====

1.) You'll need to have C++ (g++), QT5, and git installed on your system. Slackware 15.0 comes with these pre-installed, but your distro may not.

2.) Not necessarily a requirement, but a nice thing to have, is a text editor that does syntax highlighting and shows line numbers; it makes looking at code much easier. I use vim, but any other one will do.

3.) You may need to run the compiling commands in step 10 as a user with root privileges, in which case, you'll need to precede the commands with "sudo ".

4.) I've written this guide assuming that you a) are familiar with the Linux command line, and b) you don't have a lot of coding experience.

5.) You'll need to be connected to the internet when running the git command in step 2.

==== Procedure ====

 

NOTE1: I stand on the shoulders of giants. I did not come up with these fixes myself; I have simply collected these fixes from various commits to get NifSkope to work natively on my system.

NOTE2: In the commands I give below you will notice that I add comments to the code with either hashes ("#") or enclosed forward slashes and asterisks ("/*", "*/"). You don't have to add these, I just added them for clarity.

1.) Find yourself a nice clean, safe place to store your project. I created a directory called "src" in my home folder, and I build all my stuff there.

2.) Open a terminal, and go to your safe place (i.e. "src"). Now type the following command and hit enter (this will create a folder called "nifskope" and populate it with all of the necessary source code):

git clone --recursive https://github.com/niftools/nifskope

3.) Now, go into the nifskope directory and run the following:

git submodule update

This may not be strictly necessary (the "--recursive" git option may already do this), but I do it anyway just to be sure.

4.) NifSkope code comes with some empty library directories (licensing issues?), and this is what was kicking my posterior for the most part. It turns out I was cloning the wrong git source tree <forehead smack>. If you use the git command above, you should be good, but let's double-check.

From the nifskope directory, descend into the "lib" folder. In there, verify that the "gli", "qhull", and "zlib" folders are NOT empty.

If they're devoid of files, something went wrong with your git pull in step 2, so maybe double check the address. You can always use your web browser to go to that address, then click your way through the source tree to the same folders as above. They should appear as links to other source code repositories, so your git command above should be following those links and pulling the code.

5.) You'll have to make some minor tweaks to the code to get this to work. Go back up to the nifskope directory, descend into the "src" directory (not your safe place, but the "src" folder in the nifskope folder), then go into the "ui" folder, and then the "widgets" folder. Open the "lightingwidget.h" file in your favorite editor:

vim lightingwidget.h

About four lines down, you'll see the following:

#include <QWidget>

Add the following line after it, so it looks like this:

#include <QWidget>
#include <QAction>    /* new line! */

Then, go down to about line nine. You should see this:

class QAction;

Change it to look like this (NOTE2 above does not apply here):

/* class QAction; */

This tells your compiler to ignore the code, but you've preserved it in case it's needed in the future. Go ahead and save the file now.

6.) While in the same directory, go ahead and edit the following:

vim lightingwidget.cpp

Now add the following line after "#include "glview.h"" on line four:

#include "glview.h"
#include <QAction>    /* new line! */

All done, go ahead and save the file.

7.) If you plan on doing any Fallout 4 modding, there is another change we can make while in the "widgets" directory. This edit is pretty substantial, so I'm not going to include it here (this step is for a texture display fix and is entirely optional); however, I will include a link to the fix and you can make the edit yourself if you so choose:

https://github.com/niftools/nifskope/pull/120/commits/b28c0065e9256b265eed9c30635e9fe3885bc4a0

This is a patch for the "uvedit.cpp" file. Essentially, wherever you see a minus sign ("-") preceding a line, delete that line, and wherever you see a plus sign ("+") preceding a line, add that code to the file.

Go ahead and save the file once you are done.

8.) Next, ascend back up to the "ui" directory, and edit the following file:

vim nifskope.ui

On line thirteen, delete the space after "centeralwidget" and before the forward slash, so it looks like this:

 <widget class="QWidget" name="centralwidget"/>

Then, on line 416 you'll see:

background: url(":/img/sizeGrip") no-repeat;

Change the text "img" in the line to "wnd":

background: url(":/wnd/sizeGrip") no-repeat;

Isn't hacking fun? Go ahead and save the file.

9.) One more edit <cracks knuckles>. Head back up to the nifskope directory and edit the following:

vim NifSkope_targets.pri

Go down to line 122 and make the following changes:

if(!isEmpty(dot)) {    # new line!
    exists($$dot) {
        HAVE_DOT = YES
        DOT_PATH = $$re_escape($${dot})
    }                  # new line!
}

Add spaces to the beginning of the lines as necessary to make it look like the above. This has no effect on compilation, but it makes the code easier to look at. Save your changes.

10.) OK, it's crunching time. While still in the nifskope directory, enter the following:

qmake-qt5

You should see a message about a created ".qmake.stash" file and you will notice a new file named "Makefile" in the nifskope directory.

Note:  On Slackware 15.0, "qmake-qt5" is just a symlink to "qmake", so you could try just "qmake" if you're getting "File not found" errors, but you may need to check your distro for the correct command to start qmake.

Next, enter the following two commands in succession to build NifSkope:

make
make docs

If the compile was successful, you should now have a new folder in the nifskope directory called "release", which contains the NifSkope executable and everything it needs to run:

.
..
doc
shaders
CHANGELOG.txt
LICENSE.txt
NifSkope
README.txt
kfm.xml
list.txt
nif.xml
style.qss

Enter the following while in the "release" folder to enjoy your shiny new Linux-native NifSkope!

./NifSkope

If the compile was not successful, look closely at the errors. It will usually tell you which file the compiler had an issue with and generally what the hiccup was. Chances are you mistyped something above. Before you make any changes though, enter the following commands while in the nifskope directory to start with a clean slate:

make clean
rm .qmake.stash
rm Makefile

11.) Bonus step (because this one goes to eleven!)

The nifskope source does not provide a means of installing the executable on your system (there is some code for building an "rpm" package, but that's specific to Red Hat based distros like Fedora). Here's what I did to integrate NifSkope into mine.

 

First, I created a new folder in my home directory called "bin" and added it to my PATH variable in my ".profile" and ".bash_profile" files:

PATH=$PATH:$HOME/bin

Next, I made a folder in "bin" called "NifSkope" and copied the contents of the nifskope source "release" folder into it. I then linked the NIfSkope executable to "nifskope" in my "bin" directory:

ln -s ~/bin/NifSkope/NifSkope ~/bin/nifskope

Now, when I type "nifskope" in a terminal or a command launcher, NifSkope will start up in all its glory. If you prefer to use a GUI, you can create a custom launcher that points to this file. The "res" folder in the nifskope source directory contains icon files if you want to get fancy.

==== Known Issues ====

Textures may not display on your meshes in the NifSkope render window. If your rendered mesh is pink or white and is not displaying any textures, try these steps:

a.) Go to Options >> Settings >> Resources and make sure you have added the paths to your game's data directory or archive file. For Bethesda games, the path should be to the "Data" folder (not the "textures" folder) and/or the texture BSA files.

b.) Windows path structures use the backslash "\" character to separate directories. Linux uses the forward slash "/" instead (the backslash character is used for escape sequences). Click on the mesh itself in the render window. In the block tree to the left, double-click the highlighted block to expand it (e.g. "NiTrShapeData"). Now double-click on the revealed "BSLightingShaderProperty", then click on the revealed "BSShaderTetxureSet" to highlight it. In the lower left window you should see a list of the textures assigned to the mesh. Notice that the texture paths are probably using backslashes (most mod authors use Windows). Double-click the texture name to edit it and change the backslashes ("\") to forward slashes ("/"), then hit enter. Voila!

c.) Another thing to keep in mind is that unlike WIndows, Linux is case-sensitive. If you follow along with step b above, you may notice that the texture path and/or name is capitalized. Verify that the actual path/file is also capitalized, otherwise you will need to edit the texture name as above in step b, or change the name of the actual texture to match. BONUS TIP: If you click on the little purple flower next to the texture path, it will bring up a window that will let you navigate to and select your textures (click "yes" in the dialog that pops up before the file selector); however, you may still need to edit the path separators afterwards as in b above.

Enjoy!

Edited by Foxroe
Code syntax errors
Link to comment
Share on other sites

  • 8 months later...

Can you think of any reason that nifskope might not remember the resource paths I give it? I set the paths, save, exit the setup window, and when I go back it's forgotten them. It's most frustrating.

Do I need to create a .nifskope folder somewhere to store setup data or something? (Then again, it remembers the game path just fine...)

Edited by DocClox
Link to comment
Share on other sites

  • 1 month later...
Posted (edited)

I'm not really sure. I think it may have to do with the code being originally (mostly) Windows based and a Linux-native compile won't handle the Windows paths nicely - similar to the texture path bug. I'm sure there's a work-around in the code, but I haven't found it.

Edited by Foxroe
Link to comment
Share on other sites

  • 1 month later...

I have a fork of NifSkope that supports Linux, and is based on more recent code (dev9) with a number of fixes and improvements. I cannot reproduce the issue reported by DocClox, though, so I am not sure what may have been causing that. I use Linux myself and saving the paths works for me.

  • Thanks 1
Link to comment
Share on other sites

 

1 hour ago, fo76utils said:

I have a fork of NifSkope that supports Linux, and is based on more recent code (dev9) with a number of fixes and improvements.

I actually succeeded at building a working Nifskope by following the above tutorial, long story short. However, it seems to be a bit wonky. Whenever the window is unmaximzed then maximized back, I get a black dead space between two of the windows components. It can be sorted out with a back and forth resize of one of the components but it's frustrating.

See below:

nifskope7-screen.jpg

Does your build do that? And the textures aren't rendering in-app. What you see above is a glass bong and it should be slightly less opaque. Everything else I load up is the either the same color or solid white. I don't know what's going on there because I set the data paths. 

Anyways, I'm not seeking solutions from you for my issues. I'm looking to possibly upgrade. Is the procedure to compile and build your Nifskope similar to the above tutorial? Because, if not, I may need a little help. Unless you've got a freshly built Nifskope, you know, just lying around that you'd be willing to send me? I'm kidding, of course.

Link to comment
Share on other sites

1 hour ago, UsernameWithA9 said:

Does your build do that?

It does not for me on my build, I did not test dev7 though, so I cannot tell if it would have the issues you mentioned.

I did encounter problems with the UI and rendering when running NifSkope under Wayland, which can be worked around by setting the environment variable QT_QPA_PLATFORM to xcb.

Link to comment
Share on other sites

18 minutes ago, fo76utils said:

I did encounter problems with the UI and rendering when running NifSkope under Wayland, which can be worked around by setting the environment variable QT_QPA_PLATFORM to xcb.

I don't run my OS, Linux Mint, under Wayland so that shouldn't be an issue for me. You didn't answer my question though.  Is the procedure to compile and build your Nifskope similar to the above tutorial? Specifically, are there any edits to the files lightingwidget.h or lightningwidget.cpp? Or any edits, for that matter. I'm just trying to assess how painful and difficult this may be because the only knowledge I have of compiling and building comes from trudging through the tutorial above and following advice from members here in this thread.

Link to comment
Share on other sites

Posted (edited)
9 minutes ago, UsernameWithA9 said:

Specifically, are there any edits to the files lightingwidget.h or lightningwidget.cpp?

No edits should be needed, you just need to install Qt 5.15 and C++ development tools, then run qmake and make.

If you do get any compile errors on your distribution, I will update the sources on Git to fix them.

Edited by fo76utils
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...