{"action":"created","issue":{"url":"https://api.github.com/repos/bytedeco/javacpp/issues/266","repository_url":"https://api.github.com/repos/bytedeco/javacpp","labels_url":"https://api.github.com/repos/bytedeco/javacpp/issues/266/labels{/name}","comments_url":"https://api.github.com/repos/bytedeco/javacpp/issues/266/comments","events_url":"https://api.github.com/repos/bytedeco/javacpp/issues/266/events","html_url":"https://github.com/bytedeco/javacpp/issues/266","id":367945797,"node_id":"MDU6SXNzdWUzNjc5NDU3OTc=","number":266,"title":"Failing to compile simple example","user":{"login":"neil-benn","id":15836894,"node_id":"MDQ6VXNlcjE1ODM2ODk0","avatar_url":"https://avatars0.githubusercontent.com/u/15836894?v=4","gravatar_id":"","url":"https://api.github.com/users/neil-benn","html_url":"https://github.com/neil-benn","followers_url":"https://api.github.com/users/neil-benn/followers","following_url":"https://api.github.com/users/neil-benn/following{/other_user}","gists_url":"https://api.github.com/users/neil-benn/gists{/gist_id}","starred_url":"https://api.github.com/users/neil-benn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neil-benn/subscriptions","organizations_url":"https://api.github.com/users/neil-benn/orgs","repos_url":"https://api.github.com/users/neil-benn/repos","events_url":"https://api.github.com/users/neil-benn/events{/privacy}","received_events_url":"https://api.github.com/users/neil-benn/received_events","type":"User","site_admin":false},"labels":[{"id":93987297,"node_id":"MDU6TGFiZWw5Mzk4NzI5Nw==","url":"https://api.github.com/repos/bytedeco/javacpp/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-10-08T20:43:09Z","updated_at":"2018-10-09T01:47:28Z","closed_at":null,"author_association":"NONE","body":"Hello,\r\n\r\n  I'm trying to work something up and failing to succeed.  The header file looks as follows in a file called CameraIterator.h:\r\n\r\n    #pragma once\r\n\r\n    #define INITGUID\r\n    #define _CRT_NO_VA_START_VALIDATION\r\n\r\n    #include <stdio.h>\r\n    #include <tchar.h>\r\n    #include <iostream>\r\n    #include <sti.h>\r\n    #include <stdlib.h>\r\n    #include <errno.h>\r\n    #include <Windows.h>\r\n    #include <vector>\r\n\r\n    using namespace std;\r\n\r\n    namespace CameraIteratorLibrary {\r\n\r\n\tclass CameraIteratorClass {\r\n\tpublic:\r\n\t\t__declspec(dllexport) CameraIteratorClass();\r\n\t\t__declspec(dllexport) ~CameraIteratorClass();\r\n\t\t__declspec(dllexport) int listDevices();\r\n\t\t__declspec(dllexport) std::vector <std::string> getDeviceList();\r\n\r\n\r\n\tprivate:\r\n\r\n\t\t//don't touch\r\n\t\tstatic bool comInit();\r\n\t\tstatic bool comUnInit();\r\n\t\tstatic char deviceNames[20][255];\r\n\t};\r\n    }\r\n\r\nThe cpp class is as follows (implementation code snipped for brevity):\r\n\r\n---\r\n    #include \"CameraIterator.h\"\r\n    #include <tchar.h>\r\n\r\n    //Include Directshow stuff here so we don't worry about needing all the h files.\r\n    #include <dshow.h>\r\n    #pragma comment(lib,\"Strmiids.lib\") \r\n    #include <windows.h>\r\n\r\n    //for threading\r\n    #include <process.h>\r\n\r\n    namespace CameraIteratorLibrary\r\n    {\r\n\r\n\tstatic bool VI_COM_MULTI_THREADED = false;\r\n\tstatic int comInitCount = 0;\r\n\r\n\t////////////////////////////  PUBLIC METHODS  ///////////////////////////////\r\n\r\n\tCameraIteratorClass::CameraIteratorClass() {\r\n\t\t//start com\r\n\t\tcomInit();\r\n\t}\r\n\r\n\tchar CameraIteratorClass::deviceNames[20][255] = { {0} };\r\n\r\n\tstd::vector <std::string> CameraIteratorClass::getDeviceList() {\r\n\t\tint numDev = CameraIteratorClass::listDevices();\r\n\t\tstd::vector <std::string> deviceList;\r\n\t\tfor (int i = 0; i < numDev; i++) {\r\n\t\t\tconst char * name = deviceNames[i];\r\n\t\t\tif (name == NULL)break;\r\n\t\t\tdeviceList.push_back(name);\r\n\t\t}\r\n\t\treturn deviceList;\r\n\t}\r\n\r\n\tint CameraIteratorClass::listDevices() {\r\n\t\t//COM Library Intialization\r\n\t\tcomInit();\r\n\t\t<snip>\r\n\t\treturn deviceCounter;\r\n\t}\r\n\r\n\tCameraIteratorClass::~CameraIteratorClass() {\r\n\t\t//Unitialize com\r\n\t\tcomUnInit();\r\n\t}\r\n\r\n\tbool CameraIteratorClass::comInit() {\r\n                <snip>\r\n\t\treturn true;\r\n\t}\r\n\r\n\tbool CameraIteratorClass::comUnInit() {\r\n                <snip>\r\n                return false;\r\n\t}\r\n}\r\n\r\nThe Java class is as follows:\r\n\r\n    import org.bytedeco.javacpp.*;\r\n    import org.bytedeco.javacpp.annotation.*;\r\n\r\n    @Platform(include = \"CameraIterator.h\")\r\n    public class CameraIteratorLibrary extends Pointer {\r\n\t\r\n        public static class CameraIteratorClass extends Pointer {\r\n            static { Loader.load(); }\r\n            public CameraIteratorClass() { allocate(); }\r\n            private native void allocate();\r\n\r\n            // to call the getter and setter functions \r\n            public static native int listDevices();\r\n\r\n        }\r\n    \r\n        public static void main(String[] args) {\r\n            CameraIteratorClass.listDevices();\r\n        }\r\n    }\r\n\r\n  I know this code works in plain ol' C++ as it works from Visual Studio with no problem.\r\n\r\n  I've then dropped the CameraIterator.h file, CameraIterator.dll and CameraIterator.lib in a directory with the java source file - CameraIteratorLibrary.java.  \r\n\r\nExecuting javac CameraIteratorLibrary.java -cp ..\\..\\lib\\javacpp-1.4.2.jar CameraIteratorLibrary.java works just fine.  \r\n\r\nThen in this directory I am executing \"c:\\Program Files\\Java\\jdk1.8.0_162\\bin\\java.exe\" -jar ..\\..\\lib\\javacpp-1.4.2.jar CameraIteratorLibrary.  However this gives me a load of warnings followed by:\r\n```\r\n   Creating library jniCameraIteratorLibrary.lib and object jniCameraIteratorLibrary.exp\r\njniCameraIteratorLibrary.obj : error LNK2001: unresolved external symbol \"public: static int __cdecl CameraIteratorLibrary::CameraIteratorClass::listDevices(void)\" (?listDevices@CameraIteratorClass@CameraIteratorLibrary@@SAHXZ)\r\njniCameraIteratorLibrary.obj : error LNK2001: unresolved external symbol \"public: __thiscall CameraIteratorLibrary::CameraIteratorClass::~CameraIteratorClass(void)\" (??1CameraIteratorClass@CameraIteratorLibrary@@QAE@XZ)\r\njniCameraIteratorLibrary.obj : error LNK2001: unresolved external symbol \"public: __thiscall CameraIteratorLibrary::CameraIteratorClass::CameraIteratorClass(void)\" (??0CameraIteratorClass@CameraIteratorLibrary@@QAE@XZ)\r\njniCameraIteratorLibrary.dll : fatal error LNK1120: 3 unresolved externals\r\nException in thread \"main\" java.lang.RuntimeException: Process exited with an error: 2\r\n        at org.bytedeco.javacpp.tools.Builder.generateAndCompile(Builder.java:515)\r\n        at org.bytedeco.javacpp.tools.Builder.build(Builder.java:931)\r\n        at org.bytedeco.javacpp.tools.Builder.main(Builder.java:1125)\r\n```\r\n  It's like it can't find the dll but everything (for now) is in the same folder.  Does anybody have any suggestions as to why it can't seem to find the correct files and/or what I am doing wrong?\r\n\r\nCheers,\r\n\r\nNeil\r\n"},"comment":{"url":"https://api.github.com/repos/bytedeco/javacpp/issues/comments/428032568","html_url":"https://github.com/bytedeco/javacpp/issues/266#issuecomment-428032568","issue_url":"https://api.github.com/repos/bytedeco/javacpp/issues/266","id":428032568,"node_id":"MDEyOklzc3VlQ29tbWVudDQyODAzMjU2OA==","user":{"login":"saudet","id":3328023,"node_id":"MDQ6VXNlcjMzMjgwMjM=","avatar_url":"https://avatars1.githubusercontent.com/u/3328023?v=4","gravatar_id":"","url":"https://api.github.com/users/saudet","html_url":"https://github.com/saudet","followers_url":"https://api.github.com/users/saudet/followers","following_url":"https://api.github.com/users/saudet/following{/other_user}","gists_url":"https://api.github.com/users/saudet/gists{/gist_id}","starred_url":"https://api.github.com/users/saudet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saudet/subscriptions","organizations_url":"https://api.github.com/users/saudet/orgs","repos_url":"https://api.github.com/users/saudet/repos","events_url":"https://api.github.com/users/saudet/events{/privacy}","received_events_url":"https://api.github.com/users/saudet/received_events","type":"User","site_admin":false},"created_at":"2018-10-09T01:47:28Z","updated_at":"2018-10-09T01:47:28Z","author_association":"MEMBER","body":"It's also possible to do it the SWIG way with `java -jar javacpp.jar -nocompile ...`. That will give you the JNI bindings in a C++ file to build independently from JavaCPP."}}
{"actor":{"display_login":"saudet"}}