问:
What is the best way to pass a jbyteArray from (objective-c) JNI to Java?
I'm currently retrieving image data from an iSight camera and I'd like to hand it over to Java for processing. I originally tried to put the data in a jbyteArray and return the jbyteArray. This works once per process. Calling the native function a second time will result in an invalid memory access.

Since I'm working with objective-c and Cocoa, I must use the JNF_COCOA_ENTER(...) and JNF_COCOA_EXIT(...) functions. Sadly, if I can't return the jbyteArray because doing so would result in JNF_COCOA_EXIT(...) not getting called. It was suggested to use a direct ByteBuffer to pass the data from JNI land to java land. Unfortunately, all the resources and references I've been using don't outline this straightforwardly enough for my brain to comprehend. I deeply apologize if this is a "duh" moment or has already been asked (I've searched with no luck), but...

1) What is the most efficient way to bring this image data to Java?

2) How should I use the ByteBuffer class to accomplish this? (if relevant)

Thanks!

答:
Code might be helpful here.  It's not as difficult as you might imagine once you get an idea of what those macros do, and how to separate the java and cocoa concerns from each other.

What you need to remember is that JNF_COCOA_ENTER and JNF_COCOA_EXIT do two main things for you:

They establish a local scope (so variables defined inside are not available outside - this is to help you not do "dumb" things with variables you shouldn't be touching) and also to set up an auto-release pool, so cocoa objects which are "autoreleased" inside that scope will be gone when the scope disappears. (this is part of why the local scope is useful/helpful) They'll also do some exception parsing so that you can catch Cocoa exceptions in Java.

That said, the following code IS LEGAL, you just need to be quite careful about managing memory access and ownership of data.  Avoid mixing Java ownership and Objective-C ownership if possible, or else have your object manage the ownership, and clean up when the java object is GCed.

```<code>jbyteArray bytes;

JNF_COCOA_ENTER(env);

// Assign and full the bytes array here, doing any requisite transformations.
// Remember to COPY any data out of COCOA objects, as references will be dead soon!

JNF_COCOA_EXIT(env);

return bytes;
</code>```

Using Java Objects from C is complex, but not unworkable.  Still, the number of method calls is non-trivial, and the jump back and fourth is time consuming, so if you'll be calling this method often, or it's time critical, stick with the basic types as much as possible.

If you need to push data from Cocoa to Java from a delegate, things are a little bit more complicated, but not unworkable.  Here's a segment from a project I manage called QTCubed, which does exactly that.  didOutputVideoFrame is the delegate method, and this object MUST be initialized with the target Java Object Reference, and Java Environment from a JNI called method. Once initialized, it's then set as a delegate object, and receives updates from the camera.

```<code>@implementation QTKitCaptureDecompressedVideoOutput

- (QTKitCaptureDecompressedVideoOutput *)initWithEnv:(JNIEnv *) env javaObject:(jobject) javaObjectRef {
    [super init];
    // Save a reference to the VM
    (*env)->GetJavaVM(env,&g_vm);
    // Create a global reference to this object so we can access it later
    objectRef = (*env)->NewGlobalRef(env,javaObjectRef);

    return self;
}

- (void)captureOutput:(QTCaptureOutput *)captureOutput didOutputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection {
    // Move into Java to deliver the data
    JNIEnv *env;
    (*g_vm)->AttachCurrentThread (g_vm, (void **) &env, NULL);

    void * rawData = [sampleBuffer bytesForAllSamples];
    int length = [sampleBuffer lengthForAllSamples];
    QTFormatDescription * formatDescription = [sampleBuffer formatDescription];
    QTTime duration = [sampleBuffer duration];

    float frameDuration = duration.timeValue/duration.timeScale;
    float fps = 1/frameDuration;

    jint format = [formatDescription formatType];
    NSValue * pixelSize = [formatDescription attributeForKey:QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
    NSSize size = [pixelSize sizeValue];
    jint width = size.width;
    jint height = size.height;
    //NSLog(@"Outputting frame sized %d x %d of length %d with format: %#x",width,height,length,format);

    switch (format) {
            // 8 bit codecs
        case kCVPixelFormatType_1Monochrome:
        case kCVPixelFormatType_2Indexed:
        case kCVPixelFormatType_4Indexed:
        case kCVPixelFormatType_8Indexed:
        case kCVPixelFormatType_1IndexedGray_WhiteIsZero:
        case kCVPixelFormatType_2IndexedGray_WhiteIsZero:
        case kCVPixelFormatType_4IndexedGray_WhiteIsZero:
        case kCVPixelFormatType_8IndexedGray_WhiteIsZero:
        case kCVPixelFormatType_422YpCbCr8:
        case kCVPixelFormatType_4444YpCbCrA8:
        case kCVPixelFormatType_4444YpCbCrA8R:
        case kCVPixelFormatType_444YpCbCr8:
        case kCVPixelFormatType_420YpCbCr8Planar:
        case kCVPixelFormatType_422YpCbCr_4A_8BiPlanar:
        case kCVPixelFormatType_24RGB:
        case kCVPixelFormatType_24BGR:
        default:
        {
            // Re-use the existing array if possible
            if (byteFrameData == nil || (*env)->GetArrayLength(env,byteFrameData) < length) {
                // Clean up the previously allocated global reference
                if (byteFrameData != nil) {
                    (*env)->DeleteGlobalRef(env,byteFrameData);
                    byteFrameData = nil;
                }
                // Create an appropriately sized byte array to hold the data
                byteFrameData = (*env)->NewGlobalRef(env,(*env)->NewByteArray(env,length));
            }
            if (byteFrameData) {
                // Copy the raw data into the byteArray
                (*env)->SetByteArrayRegion(env,byteFrameData,0,length,rawData);

                // Get the class reference for our object
                jclass classRef = (*env)->GetObjectClass(env,objectRef);
                // Get the pushFrame methodId
                jmethodID methodId = (*env)->GetMethodID(env,classRef,"pushFrame","([BIIIF)V");
                // Call pushFrame with the byte array
                (*env)->CallVoidMethod(env,objectRef,methodId,byteFrameData,format,width,height,fps);
            }
            break;
        }
            // 16 bit (short) storage of values
        case kCVPixelFormatType_16BE555:
        case kCVPixelFormatType_16LE555:
        case kCVPixelFormatType_16LE5551:
        case kCVPixelFormatType_16BE565:
        case kCVPixelFormatType_16LE565:
        case kCVPixelFormatType_16Gray:
        case kCVPixelFormatType_422YpCbCr16:
        case kCVPixelFormatType_422YpCbCr10:
        case kCVPixelFormatType_444YpCbCr10:
        {
            // Re-use the existing array if possible
            if (shortFrameData == nil || (*env)->GetArrayLength(env,shortFrameData) < length/2) {
                // Clean up the previously allocated global reference
                if (shortFrameData != nil) {
                    (*env)->DeleteGlobalRef(env,shortFrameData);
                    shortFrameData = nil;
                }
                // Create an appropriately sized byte array to hold the data
                shortFrameData = (*env)->NewGlobalRef(env,(*env)->NewShortArray(env,length/2));
            }
            if (shortFrameData) {
                // Copy the raw data into the byteArray
                (*env)->SetShortArrayRegion(env,shortFrameData,0,length/2,rawData);

                // Get the class reference for our object
                jclass classRef = (*env)->GetObjectClass(env,objectRef);
                // Get the pushFrame methodId
                jmethodID methodId = (*env)->GetMethodID(env,classRef,"pushFrame","([SIIIF)V");
                // Call pushFrame with the short array
                (*env)->CallVoidMethod(env,objectRef,methodId,shortFrameData,format,width,height,fps);
            }
            break;
        }
            // 32 bit (int) storage of values
        case kCVPixelFormatType_32ABGR:
        case kCVPixelFormatType_32AlphaGray:
        case kCVPixelFormatType_32ARGB:
        case kCVPixelFormatType_32BGRA:
        case kCVPixelFormatType_32RGBA:
        {
            // Re-use the existing array if possible
            if (intFrameData == nil || (*env)->GetArrayLength(env,intFrameData) < length/4) {
                // Clean up the previously allocated global reference
                if (intFrameData != nil) {
                    (*env)->DeleteGlobalRef(env,intFrameData);
                    intFrameData = nil;
                }
                // Create an appropriately sized byte array to hold the data
                intFrameData = (*env)->NewGlobalRef(env,(*env)->NewIntArray(env,length/4));
            }
            if (intFrameData) {
                // Copy the raw data into the byteArray
                (*env)->SetByteArrayRegion(env,intFrameData,0,length/4,rawData);

                // Get the class reference for our object
                jclass classRef = (*env)->GetObjectClass(env,objectRef);
                // Get the pushFrame methodId
                jmethodID methodId = (*env)->GetMethodID(env,classRef,"pushFrame","([IIIIF)V");
                // Call pushFrame with the int array
                (*env)->CallVoidMethod(env,objectRef,methodId,intFrameData,format,width,height,fps);
            }
            break;
        }
    }

    // Detatch from Java
    (*g_vm)->DetachCurrentThread (g_vm);
}

/* Clean up java references so they can be properly GCed in java */
- (void) dealloc {

    // Attach to java so we can release references
    JNIEnv *env;
    (*g_vm)->AttachCurrentThread (g_vm, (void **) &env, NULL);

    // release the references we hold

    if (objectRef != nil) {
        (*env)->DeleteGlobalRef(env,objectRef);
        objectRef = nil;
    }
    if (byteFrameData != nil) {
        (*env)->DeleteGlobalRef(env,byteFrameData);
        byteFrameData = nil;
    }
    if (shortFrameData != nil) {
        (*env)->DeleteGlobalRef(env,shortFrameData);
        shortFrameData = nil;
    }
    if (intFrameData != nil) {
        (*env)->DeleteGlobalRef(env,intFrameData);
        intFrameData = nil;
    }

    // Detatch from Java
    (*g_vm)->DetachCurrentThread (g_vm);

    g_vm = nil;

    [super dealloc];
}

@end
</code>```

Here's the method signature on the java side for the java object reference that is passed in:

```<code>protected void pushFrame(byte[] frameData, int formatInt, int width, int height, float frameRate);
protected void pushFrame(short[] frameData, int formatInt, int width, int height, float frameRate);
protected void pushFrame(int[] frameData, int formatInt, int width, int height, float frameRate);
</code>```

Once you have a running application, USE INSTRUMENTS TO MAKE SURE YOU'RE DISPOSING OF REFERENCES PROPERLY!

Body:
Code might be helpful here.  It's not as difficult as you might imagine once you get an idea of what those macros do, and how to separate the java and cocoa concerns from each other.

What you need to remember is that JNF_COCOA_ENTER and JNF_COCOA_EXIT do two main things for you:

They establish a local scope (so variables defined inside are not available outside - this is to help you not do "dumb" things with variables you shouldn't be touching) and also to set up an auto-release pool, so cocoa objects which are "autoreleased" inside that scope will be gone when the scope disappears. (this is part of why the local scope is useful/helpful) They'll also do some exception parsing so that you can catch Cocoa exceptions in Java.

That said, the following code IS LEGAL, you just need to be quite careful about managing memory access and ownership of data.  Avoid mixing Java ownership and Objective-C ownership if possible, or else have your object manage the ownership, and clean up when the java object is GCed.

jbyteArray bytes;

JNF_COCOA_ENTER(env);

// Assign and full the bytes array here, doing any requisite transformations.
// Remember to COPY any data out of COCOA objects, as references will be dead soon!

JNF_COCOA_EXIT(env);

return bytes;

Using Java Objects from C is complex, but not unworkable.  Still, the number of method calls is non-trivial, and the jump back and fourth is time consuming, so if you'll be calling this method often, or it's time critical, stick with the basic types as much as possible.

If you need to push data from Cocoa to Java from a delegate, things are a little bit more complicated, but not unworkable.  Here's a segment from a project I manage called QTCubed, which does exactly that.  didOutputVideoFrame is the delegate method, and this object MUST be initialized with the target Java Object Reference, and Java Environment from a JNI called method. Once initialized, it's then set as a delegate object, and receives updates from the camera.

@implementation QTKitCaptureDecompressedVideoOutput

- (QTKitCaptureDecompressedVideoOutput *)initWithEnv:(JNIEnv *) env javaObject:(jobject) javaObjectRef {
    [super init];
    // Save a reference to the VM
    (*env)->GetJavaVM(env,&g_vm);
    // Create a global reference to this object so we can access it later
    objectRef = (*env)->NewGlobalRef(env,javaObjectRef);

    return self;
}

- (void)captureOutput:(QTCaptureOutput *)captureOutput didOutputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection {
    // Move into Java to deliver the data
    JNIEnv *env;
    (*g_vm)->AttachCurrentThread (g_vm, (void **) &env, NULL);

    void * rawData = [sampleBuffer bytesForAllSamples];
    int length = [sampleBuffer lengthForAllSamples];
    QTFormatDescription * formatDescription = [sampleBuffer formatDescription];
    QTTime duration = [sampleBuffer duration];

    float frameDuration = duration.timeValue/duration.timeScale;
    float fps = 1/frameDuration;

    jint format = [formatDescription formatType];
    NSValue * pixelSize = [formatDescription attributeForKey:QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
    NSSize size = [pixelSize sizeValue];
    jint width = size.width;
    jint height = size.height;
    //NSLog(@"Outputting frame sized %d x %d of length %d with format: %#x",width,height,length,format);

    switch (format) {
            // 8 bit codecs
        case kCVPixelFormatType_1Monochrome:
        case kCVPixelFormatType_2Indexed:
        case kCVPixelFormatType_4Indexed:
        case kCVPixelFormatType_8Indexed:
        case kCVPixelFormatType_1IndexedGray_WhiteIsZero:
        case kCVPixelFormatType_2IndexedGray_WhiteIsZero:
        case kCVPixelFormatType_4IndexedGray_WhiteIsZero:
        case kCVPixelFormatType_8IndexedGray_WhiteIsZero:
        case kCVPixelFormatType_422YpCbCr8:
        case kCVPixelFormatType_4444YpCbCrA8:
        case kCVPixelFormatType_4444YpCbCrA8R:
        case kCVPixelFormatType_444YpCbCr8:
        case kCVPixelFormatType_420YpCbCr8Planar:
        case kCVPixelFormatType_422YpCbCr_4A_8BiPlanar:
        case kCVPixelFormatType_24RGB:
        case kCVPixelFormatType_24BGR:
        default:
        {
            // Re-use the existing array if possible
            if (byteFrameData == nil || (*env)->GetArrayLength(env,byteFrameData) < length) {
                // Clean up the previously allocated global reference
                if (byteFrameData != nil) {
                    (*env)->DeleteGlobalRef(env,byteFrameData);
                    byteFrameData = nil;
                }
                // Create an appropriately sized byte array to hold the data
                byteFrameData = (*env)->NewGlobalRef(env,(*env)->NewByteArray(env,length));
            }
            if (byteFrameData) {
                // Copy the raw data into the byteArray
                (*env)->SetByteArrayRegion(env,byteFrameData,0,length,rawData);

                // Get the class reference for our object
                jclass classRef = (*env)->GetObjectClass(env,objectRef);
                // Get the pushFrame methodId
                jmethodID methodId = (*env)->GetMethodID(env,classRef,"pushFrame","([BIIIF)V");
                // Call pushFrame with the byte array
                (*env)->CallVoidMethod(env,objectRef,methodId,byteFrameData,format,width,height,fps);
            }
            break;
        }
            // 16 bit (short) storage of values
        case kCVPixelFormatType_16BE555:
        case kCVPixelFormatType_16LE555:
        case kCVPixelFormatType_16LE5551:
        case kCVPixelFormatType_16BE565:
        case kCVPixelFormatType_16LE565:
        case kCVPixelFormatType_16Gray:
        case kCVPixelFormatType_422YpCbCr16:
        case kCVPixelFormatType_422YpCbCr10:
        case kCVPixelFormatType_444YpCbCr10:
        {
            // Re-use the existing array if possible
            if (shortFrameData == nil || (*env)->GetArrayLength(env,shortFrameData) < length/2) {
                // Clean up the previously allocated global reference
                if (shortFrameData != nil) {
                    (*env)->DeleteGlobalRef(env,shortFrameData);
                    shortFrameData = nil;
                }
                // Create an appropriately sized byte array to hold the data
                shortFrameData = (*env)->NewGlobalRef(env,(*env)->NewShortArray(env,length/2));
            }
            if (shortFrameData) {
                // Copy the raw data into the byteArray
                (*env)->SetShortArrayRegion(env,shortFrameData,0,length/2,rawData);

                // Get the class reference for our object
                jclass classRef = (*env)->GetObjectClass(env,objectRef);
                // Get the pushFrame methodId
                jmethodID methodId = (*env)->GetMethodID(env,classRef,"pushFrame","([SIIIF)V");
                // Call pushFrame with the short array
                (*env)->CallVoidMethod(env,objectRef,methodId,shortFrameData,format,width,height,fps);
            }
            break;
        }
            // 32 bit (int) storage of values
        case kCVPixelFormatType_32ABGR:
        case kCVPixelFormatType_32AlphaGray:
        case kCVPixelFormatType_32ARGB:
        case kCVPixelFormatType_32BGRA:
        case kCVPixelFormatType_32RGBA:
        {
            // Re-use the existing array if possible
            if (intFrameData == nil || (*env)->GetArrayLength(env,intFrameData) < length/4) {
                // Clean up the previously allocated global reference
                if (intFrameData != nil) {
                    (*env)->DeleteGlobalRef(env,intFrameData);
                    intFrameData = nil;
                }
                // Create an appropriately sized byte array to hold the data
                intFrameData = (*env)->NewGlobalRef(env,(*env)->NewIntArray(env,length/4));
            }
            if (intFrameData) {
                // Copy the raw data into the byteArray
                (*env)->SetByteArrayRegion(env,intFrameData,0,length/4,rawData);

                // Get the class reference for our object
                jclass classRef = (*env)->GetObjectClass(env,objectRef);
                // Get the pushFrame methodId
                jmethodID methodId = (*env)->GetMethodID(env,classRef,"pushFrame","([IIIIF)V");
                // Call pushFrame with the int array
                (*env)->CallVoidMethod(env,objectRef,methodId,intFrameData,format,width,height,fps);
            }
            break;
        }
    }

    // Detatch from Java
    (*g_vm)->DetachCurrentThread (g_vm);
}

/* Clean up java references so they can be properly GCed in java */
- (void) dealloc {

    // Attach to java so we can release references
    JNIEnv *env;
    (*g_vm)->AttachCurrentThread (g_vm, (void **) &env, NULL);

    // release the references we hold

    if (objectRef != nil) {
        (*env)->DeleteGlobalRef(env,objectRef);
        objectRef = nil;
    }
    if (byteFrameData != nil) {
        (*env)->DeleteGlobalRef(env,byteFrameData);
        byteFrameData = nil;
    }
    if (shortFrameData != nil) {
        (*env)->DeleteGlobalRef(env,shortFrameData);
        shortFrameData = nil;
    }
    if (intFrameData != nil) {
        (*env)->DeleteGlobalRef(env,intFrameData);
        intFrameData = nil;
    }

    // Detatch from Java
    (*g_vm)->DetachCurrentThread (g_vm);

    g_vm = nil;

    [super dealloc];
}

@end

Here's the method signature on the java side for the java object reference that is passed in:

protected void pushFrame(byte[] frameData, int formatInt, int width, int height, float frameRate);
protected void pushFrame(short[] frameData, int formatInt, int width, int height, float frameRate);
protected void pushFrame(int[] frameData, int formatInt, int width, int height, float frameRate);

Once you have a running application, USE INSTRUMENTS TO MAKE SURE YOU'RE DISPOSING OF REFERENCES PROPERLY!


来源: stackexchange

问:
How to move a Python Interpreter directory without reinstall or creating a virtual environment on Windows?
I want to move my python interpreter from D:\Softwares\Python to D:\Softwares\Python\Python3.7 which was originally installed in the first directory without reinstalling or creating a virtual environment on Windows.

I just simply created a new folder Python3.7 and moved the files. Then I updated the PYTHONPATH environment variable.

If I run python -v in cmd, I can correctly see the version. But when I run scrapy shell [url], there's an error:

```<code>Fatal error in launcher: Unable to create process using '"d:\softwares\python\python.exe"  "D:\Softwares\Python\Python3.7\Scripts\scrapy.exe" shell http://guba.eastmoney.com/list,cjpl.html': ???????????
</code>```

I know there's something wrong with my python.exe path, but I don't know how to fix it without reinstalling the interpreter.

I'd appreciate it a lot for your help.

note: I've already changed the environment variable path.

答: I find the solution. Just reinstalling scrapy works.

ContentLicense: CC BY-SA 4.0

Body:
I want to move my python interpreter from D:\Softwares\Python to D:\Softwares\Python\Python3.7 which was originally installed in the first directory without reinstalling or creating a virtual environment on Windows.

I just simply created a new folder Python3.7 and moved the files. Then I updated the PYTHONPATH environment variable.

If I run python -v in cmd, I can correctly see the version. But when I run scrapy shell [url], there's an error:

Fatal error in launcher: Unable to create process using '"d:\softwares\python\python.exe"  "D:\Softwares\Python\Python3.7\Scripts\scrapy.exe" shell http://guba.eastmoney.com/list,cjpl.html': ???????????

I know there's something wrong with my python.exe path, but I don't know how to fix it without reinstalling the interpreter.

I'd appreciate it a lot for your help.

note: I've already changed the environment variable path.


问:
Facebook oauth2 login returns (400) bad request
I'm converting my C# ASP.NET MVC 4 facebook login to a VB ASP.NET MVC 2 version project.

Unfortunately i am getting this error which i can't figure out what the problem is.

The main error: Bad Request 400 error.
More detailed error:

WWW-Authenticate: OAuth "Facebook Platform" "invalid_code" "Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request"

Controller:

```<code><HttpPost> _
    <AllowAnonymous> _
    Public Function ExternalLogin(provider As String, returnUrl As String) As ActionResult
        Return New ExternalLoginResult(provider, Url.Action("ExternalLoginCallback", New With { _
            Key .ReturnUrl = returnUrl _
        }))
    End Function

    Public Function ExternalLoginCallback(returnUrl As String) As ActionResult
        Dim result As AuthenticationResult = OAuthWebSecurity.VerifyAuthentication(Url.Action("ExternalLoginCallback", New With { _
            Key .ReturnUrl = returnUrl _
        }))

        ' Eind resultaat krijg je hier
        If result.IsSuccessful Then
            ' Temporary Properties
            Dim strTempGeslacht As String = result.ExtraData("gender")

            ' Properties
            Dim strVoornaam As String = result.ExtraData("firstname")
            Dim strAchternaam As String = result.ExtraData("lastname")
            Dim strEmail As String = result.ExtraData("email")
            Dim strGeboortePlaats As String = result.ExtraData("hometown")
            Dim strWoonplaats As String = result.ExtraData("location")
            Dim arrayWerk As String() = result.ExtraData("work").Split("*"C)
            Dim intGeslacht As Integer = If(strTempGeslacht = "male", 0, 1)
            Dim intOpenID As Int64 = Int64.Parse(result.ProviderUserId)
            Dim CiDutch As New CultureInfo("nl-NL", False)
            Dim strBirthday As String = String.Format("{0:dd/MM/yyyy}", result.ExtraData("birthday"))

            ' Redirect
            Return RedirectToAction("Facebook", "Bedankt")
        End If

        ' Error
        Return RedirectToAction("Index", "Home")
    End Function

    Friend Class ExternalLoginResult
        Inherits ActionResult
        Public Sub New(provider__1 As String, returnUrl__2 As String)
            Provider = provider__1
            ReturnUrl = "http://localhost:25806/Facebook/ExternalLoginCallback"
        End Sub

        Public Provider As String
        Public ReturnUrl As String

        Public Overrides Sub ExecuteResult(context As ControllerContext)
            OAuthWebSecurity.RequestAuthentication(Provider, ReturnUrl)
        End Sub
    End Class

End Class
</code>```

Query Acces Token (the error occurs here when using downloadstring)

```<code> protected override string QueryAccessToken(Uri returnUrl, string authorizationCode)
        {
            WebClient client = new WebClient();
            string url = string.Format("{0}?client_id={1}&client_secret={2}&redirect_uri={3}&code={4}", TokenEP, this._appId, this._appSecret, HttpUtility.UrlEncode(returnUrl.ToString()), authorizationCode);

            string content = client.DownloadString(url);

            NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(content);
            if (nameValueCollection != null)
            {
                string result = nameValueCollection["access_token"];
                return result;
            }
            return null;

        }
</code>```

Query url:

```<code>"https://graph.facebook.com/oauth/access_token?client_id=607648425938521&client_secret=ff099b80cc19da0ec0870df99fa465b0&redirect_uri=http%3a%2f%2flocalhost%3a18774%2fvacatures%2fExternalLoginCallBack%3f__provider__%3dfacebook%26__sid__%3d3dda4b1db178404094cbeef339d414b9&code=AQAAHJ0UoPjqvtOLjgUJ7ipzY0j7-8FxoTx7nt_Vxq9FD0cN-DhVH8BclofFEXPsPU7Fm1YHKGSlJRcLGedHSA23sVpkbssBp5yQo3PmBkUSZ9LBuckKrkjagvz4HkgFQ_oX2DoEPDmpkKo8O97GYlBt7j185SncBcpmbi8I7DNs9Z8wGP_FGQb8Mh6iMz3SH4IB1Ae3OppthmRXEJOj9k7xiboPsAYTf3w7E6MhWU3uNnR-SfA5RkSXkLas7xUnKF7eqmPM9_3pAMj2ObOAA1e4dcKke-QABo_FGx7LV0OY1pEeKIbbu9Ag5h0SBqmGi9k
</code>```

All the links are the same from the working project C# mvc 4.

答:
I have encountered this problem before.
The main mistake was that in redirect_uri, I didn't add / at the end. If the application is in test mode and Facebook says:

If only development mode is enabled, all redirects http://localhost are resolved automatically and they don't need to be added here.",

then you should add / to your redirect_uri (http://localhost:3000 /).
If this is developer mode, don't forget to add your redirect_uri   to "Valid OAuth redirect URIs". And redirect_uri in request must be the same, that in "Valid OAuth redirect URIs".

ContentLicense: CC BY-SA 3.0

Body:
I'm converting my C# ASP.NET MVC 4 facebook login to a VB ASP.NET MVC 2 version project.

Unfortunately i am getting this error which i can't figure out what the problem is.

The main error: Bad Request 400 error.
More detailed error:

WWW-Authenticate: OAuth "Facebook Platform" "invalid_code" "Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request"

Controller:

<HttpPost> _
    <AllowAnonymous> _
    Public Function ExternalLogin(provider As String, returnUrl As String) As ActionResult
        Return New ExternalLoginResult(provider, Url.Action("ExternalLoginCallback", New With { _
            Key .ReturnUrl = returnUrl _
        }))
    End Function

    Public Function ExternalLoginCallback(returnUrl As String) As ActionResult
        Dim result As AuthenticationResult = OAuthWebSecurity.VerifyAuthentication(Url.Action("ExternalLoginCallback", New With { _
            Key .ReturnUrl = returnUrl _
        }))

        ' Eind resultaat krijg je hier
        If result.IsSuccessful Then
            ' Temporary Properties
            Dim strTempGeslacht As String = result.ExtraData("gender")

            ' Properties
            Dim strVoornaam As String = result.ExtraData("firstname")
            Dim strAchternaam As String = result.ExtraData("lastname")
            Dim strEmail As String = result.ExtraData("email")
            Dim strGeboortePlaats As String = result.ExtraData("hometown")
            Dim strWoonplaats As String = result.ExtraData("location")
            Dim arrayWerk As String() = result.ExtraData("work").Split("*"C)
            Dim intGeslacht As Integer = If(strTempGeslacht = "male", 0, 1)
            Dim intOpenID As Int64 = Int64.Parse(result.ProviderUserId)
            Dim CiDutch As New CultureInfo("nl-NL", False)
            Dim strBirthday As String = String.Format("{0:dd/MM/yyyy}", result.ExtraData("birthday"))

            ' Redirect
            Return RedirectToAction("Facebook", "Bedankt")
        End If

        ' Error
        Return RedirectToAction("Index", "Home")
    End Function

    Friend Class ExternalLoginResult
        Inherits ActionResult
        Public Sub New(provider__1 As String, returnUrl__2 As String)
            Provider = provider__1
            ReturnUrl = "http://localhost:25806/Facebook/ExternalLoginCallback"
        End Sub

        Public Provider As String
        Public ReturnUrl As String

        Public Overrides Sub ExecuteResult(context As ControllerContext)
            OAuthWebSecurity.RequestAuthentication(Provider, ReturnUrl)
        End Sub
    End Class

End Class

Query Acces Token (the error occurs here when using downloadstring)

 protected override string QueryAccessToken(Uri returnUrl, string authorizationCode)
        {
            WebClient client = new WebClient();
            string url = string.Format("{0}?client_id={1}&client_secret={2}&redirect_uri={3}&code={4}", TokenEP, this._appId, this._appSecret, HttpUtility.UrlEncode(returnUrl.ToString()), authorizationCode);

            string content = client.DownloadString(url);

            NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(content);
            if (nameValueCollection != null)
            {
                string result = nameValueCollection["access_token"];
                return result;
            }
            return null;

        }

Query url:

"https://graph.facebook.com/oauth/access_token?client_id=607648425938521&client_secret=ff099b80cc19da0ec0870df99fa465b0&redirect_uri=http%3a%2f%2flocalhost%3a18774%2fvacatures%2fExternalLoginCallBack%3f__provider__%3dfacebook%26__sid__%3d3dda4b1db178404094cbeef339d414b9&code=AQAAHJ0UoPjqvtOLjgUJ7ipzY0j7-8FxoTx7nt_Vxq9FD0cN-DhVH8BclofFEXPsPU7Fm1YHKGSlJRcLGedHSA23sVpkbssBp5yQo3PmBkUSZ9LBuckKrkjagvz4HkgFQ_oX2DoEPDmpkKo8O97GYlBt7j185SncBcpmbi8I7DNs9Z8wGP_FGQb8Mh6iMz3SH4IB1Ae3OppthmRXEJOj9k7xiboPsAYTf3w7E6MhWU3uNnR-SfA5RkSXkLas7xUnKF7eqmPM9_3pAMj2ObOAA1e4dcKke-QABo_FGx7LV0OY1pEeKIbbu9Ag5h0SBqmGi9k

All the links are the same from the working project C# mvc 4.


问:
Hide Mobile Browser Address bar on full page scroll snap layout
So I've been running into this annoying problem and I don't seem to be able to fix it by myself. I'm currently working on an experimental App written Angular (11.2).

The page itself should be divided into several screen filling sections which users scroll through as if it were specific tiles. Therefor, scroll snapping is a must.

However I'm simply not capable of hiding the mobile browser address bar. This is due to the fact that, in order to get the snapping effect, the page only consists of one single element that is scaled fitting the current viewport. Also manually hiding the browser address bar using the widely used window.scrollTo(0,1) hack does not work since there is no real scrolling to be achieved.

Thus my question
Can I somehow hide the browsers address bar while still being able to keep the required layout required for scroll snapping?

答: You could use the app.manifest file to set your web-app to fullscreen. Dont know exactly if just works with installed pwas, bur you could give it a try.</p>


问:
why iPhone .app files is much larger than .ipa file?
My new iPhone application have .ipa file size (by Archive) is 2.8 MB, which is okay.
But my .app file is much large > 13 MB, and AppStore describes my app's size is 7.9 MB.

What causes this problem? Can I make my app size in AppStore is the same as my ipa file?

Thanks,

UPDATE:

When I unzip .ipa file, I see an .app file whose size is 5.2 MB!!!. It seem that I have difference configuration between these build settings. Wonder if I can use this app file to upload (beta tester can use this anyway!)

When I use iTunes to sync my downloaded app from AppStore, the .ipa size is > 13M (same as my uploaded .app)

答: Right-click on the .app file in your build folder and "Show Package Contents" and see what images and other files were included in the build.  You can look at the sizes of everything in there.  </p>


问:
How to solve PCL linking errors?
EDIT: Updated code

I'm using PCL library to generate a mesh from point clouds. This is the code, based on the Greedy Triangulation tutorial in the PCL docs:

```<code>#include <pcl/point_types.h>
#include <pcl/common/io.h>
#include <pcl/io/ply_io.h>
#include <pcl/search/kdtree.h>
#include <pcl/features/normal_3d.h>
#include <pcl/surface/gp3.h>
#include <pcl/io/obj_io.h>
#include <vector>

int main() {

    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);

    pcl::PCLPointCloud2 cloud1;
    pcl::PCLPointCloud2 cloud2;
    pcl::PCLPointCloud2 cloud3;

    pcl::io::loadPLYFile("../cam_1_2.ply", cloud1);
    pcl::io::loadPLYFile("../cam_2_3.ply", cloud2);
    pcl::io::loadPLYFile("../cam_3_4.ply", cloud3);

    cloud1 += cloud2 + cloud3;

    pcl::fromPCLPointCloud2(cloud1, *cloud);

    pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> n;
    pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>);
    pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>);

    tree->setInputCloud(cloud);
    n.setInputCloud(cloud);
    n.setSearchMethod(tree);
    n.setKSearch(20);
    n.compute(*normals);

    pcl::PointCloud<pcl::PointNormal>::Ptr cloudWithNormals(new pcl::PointCloud<pcl::PointNormal>);
    pcl::concatenateFields(*cloud, *normals, *cloudWithNormals);

    pcl::search::KdTree<pcl::PointNormal>::Ptr tree2 (new pcl::search::KdTree<pcl::PointNormal>);
    tree2->setInputCloud (cloudWithNormals);

    pcl::GreedyProjectionTriangulation<pcl::PointNormal> gp3;
    pcl::PolygonMesh triangles;

    gp3.setSearchRadius(0.025);

    gp3.setMu(2.5);
    gp3.setMaximumNearestNeighbors(100);
    gp3.setMaximumSurfaceAngle(M_PI/4);
    gp3.setMinimumAngle(M_PI/18);
    gp3.setMaximumAngle(2 * M_PI / 3);
    gp3.setNormalConsistency(false);

    gp3.setInputCloud(cloudWithNormals);
    gp3.setSearchMethod(tree2);
    gp3.reconstruct(triangles);

    std::vector<int> parts = gp3.getPartIDs();
    std::vector<int> states = gp3.getPointStates();

    pcl::io::saveOBJFile("../cam_1_2.obj", triangles);

    return 0;
}
</code>```

This is the CMakeLists file i'm using to build this:

```<code>cmake_minimum_required(VERSION 3.1 FATAL_ERROR)

project(TestProject)

find_package(PCL 1.12 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(Test main.cpp)
target_link_libraries(Test ${PCL_LIBRARIES} liblz4.so libpthread.so)
</code>```

This is the make output in terminal:

```<code> make                                                                                2 ↵
Consolidate compiler generated dependencies of target Test
[ 50%] Building CXX object CMakeFiles/Test.dir/main.cpp.o
[100%] Linking CXX executable Test
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o: in function `pcl::search::KdTree<pcl::PointXYZ, pcl::KdTreeFLANN<pcl::PointXYZ, flann::L2_Simple<float> > >::KdTree(bool)':
main.cpp:(.text._ZN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEC2Eb[_ZN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEC5Eb]+0x5e): undefined reference to `pcl::search::Search<pcl::PointXYZ>::Search(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o: in function `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::OrganizedNeighbor(bool, float, unsigned int)':
main.cpp:(.text._ZN3pcl6search17OrganizedNeighborINS_8PointXYZEEC2Ebfj[_ZN3pcl6search17OrganizedNeighborINS_8PointXYZEEC5Ebfj]+0x66): undefined reference to `pcl::search::Search<pcl::PointXYZ>::Search(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x20): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getName[abi:cxx11]() const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x28): undefined reference to `pcl::search::Search<pcl::PointXYZ>::setSortedResults(bool)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x30): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getSortedResults()'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x50): undefined reference to `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::nearestKSearch(pcl::PointXYZ const&, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x58): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x60): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x68): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, int, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x70): undefined reference to `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::radiusSearch(pcl::PointXYZ const&, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x78): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x80): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x88): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, double, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x20): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getName[abi:cxx11]() const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x30): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getSortedResults()'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x58): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x60): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x68): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, int, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x78): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x80): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x88): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, double, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x20): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getName[abi:cxx11]() const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x28): undefined reference to `pcl::search::Search<pcl::PointXYZ>::setSortedResults(bool)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x30): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getSortedResults()'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x38): undefined reference to `pcl::search::Search<pcl::PointXYZ>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&, std::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x58): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x60): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x68): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, int, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x78): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x80): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x88): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, double, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o: in function `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&, std::shared_ptr<std::vector<int, std::allocator<int> > const> const&)':
main.cpp:(.text._ZN3pcl6search17OrganizedNeighborINS_8PointXYZEE13setInputCloudERKSt10shared_ptrIKNS_10PointCloudIS2_EEERKS4_IKSt6vectorIiSaIiEEE[_ZN3pcl6search17OrganizedNeighborINS_8PointXYZEE13setInputCloudERKSt10shared_ptrIKNS_10PointCloudIS2_EEERKS4_IKSt6vectorIiSaIiEEE]+0x1ea): undefined reference to `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::estimateProjectionMatrix()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/Test.dir/build.make:154: Test] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/Test.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
</code>```

I have found a few related issues people have encountered similar to this and I have tried all the solutions provided without any help.

I am building this on Arch linux 1.4, PCL versuin 1.12.1

EDIT: Following is the output of make -j6 VERBOSE=1

```<code>
❯ make -j6 VERBOSE=1
/usr/local/bin/cmake -S/home/beany/Documents/projects/pc2mesh -B/home/beany/Documents/projects/pc2mesh/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /home/beany/Documents/projects/pc2mesh/build/CMakeFiles /home/beany/Documents/projects/pc2mesh/build//CMakeFiles/progress.marks
make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/beany/Documents/projects/pc2mesh/build'
make  -f CMakeFiles/Test.dir/build.make CMakeFiles/Test.dir/depend
make[2]: Entering directory '/home/beany/Documents/projects/pc2mesh/build'
cd /home/beany/Documents/projects/pc2mesh/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/beany/Documents/projects/pc2mesh /home/beany/Documents/projects/pc2mesh /home/beany/Documents/projects/pc2mesh/build /home/beany/Documents/projects/pc2mesh/build /home/beany/Documents/projects/pc2mesh/build/CMakeFiles/Test.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/beany/Documents/projects/pc2mesh/build'
make  -f CMakeFiles/Test.dir/build.make CMakeFiles/Test.dir/build
make[2]: Entering directory '/home/beany/Documents/projects/pc2mesh/build'
[ 50%] Building CXX object CMakeFiles/Test.dir/main.cpp.o
/opt/cuda/bin/g++ -DBOOST_ATOMIC_DYN_LINK -DBOOST_ATOMIC_NO_LIB -DBOOST_DATE_TIME_DYN_LINK -DBOOST_DATE_TIME_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_FILESYSTEM_NO_LIB -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_IOSTREAMS_NO_LIB -DBOOST_SERIALIZATION_DYN_LINK -DBOOST_SERIALIZATION_NO_LIB -DBOOST_SYSTEM_DYN_LINK -DBOOST_SYSTEM_NO_LIB -DDISABLE_PCAP -DDISABLE_PNG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -Dkiss_fft_scalar=double -isystem /usr/include/pcl-1.12 -isystem /usr/include/eigen3 -isystem /usr/include/ni -isystem /usr/include/openni2 -isystem /usr/include/vtk -isystem /usr/include/freetype2 -isystem /usr/include/qt -isystem /usr/include/qt/QtOpenGL -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtCore -isystem /usr/lib/qt/mkspecs/linux-g++ -msse4.2 -mfpmath=sse -march=native -mavx2 -pthread -fopenmp -fPIC -MD -MT CMakeFiles/Test.dir/main.cpp.o -MF CMakeFiles/Test.dir/main.cpp.o.d -o CMakeFiles/Test.dir/main.cpp.o -c /home/beany/Documents/projects/pc2mesh/main.cpp
[100%] Linking CXX executable Test
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/Test.dir/link.txt --verbose=1
/opt/cuda/bin/g++ -rdynamic CMakeFiles/Test.dir/main.cpp.o -o Test  -Wl,-rpath,/usr/lib/openmpi /usr/lib/libpcl_io.so -lOpenNI /usr/lib/libusb-1.0.so -lOpenNI2 /usr/lib/libusb-1.0.so /usr/lib/libvtkChartsCore.so.9.1.0 /usr/lib/libvtkInteractionImage.so.9.1.0 /usr/lib/libvtkIOGeometry.so.9.1.0 /usr/lib/libvtkIOPLY.so.9.1.0 /usr/lib/libvtkRenderingLOD.so.9.1.0 /usr/lib/libvtkViewsContext2D.so.9.1.0 /usr/lib/libvtkGUISupportQt.so.9.1.0 -llz4 -lpthread /usr/lib/libpcl_octree.so /usr/lib/libpcl_common.so /usr/lib/libboost_system.so.1.78.0 /usr/lib/libboost_filesystem.so.1.78.0 /usr/lib/libboost_atomic.so.1.78.0 /usr/lib/libboost_date_time.so.1.78.0 /usr/lib/libboost_iostreams.so.1.78.0 /usr/lib/libboost_serialization.so.1.78.0 /usr/lib/libjsoncpp.so /usr/lib/libvtkViewsCore.so.9.1.0 /usr/lib/libvtkInteractionWidgets.so.9.1.0 /usr/lib/libvtkFiltersModeling.so.9.1.0 /usr/lib/libvtkInteractionStyle.so.9.1.0 /usr/lib/libvtkFiltersExtraction.so.9.1.0 /usr/lib/libvtkIOLegacy.so.9.1.0 /usr/lib/libvtkIOCore.so.9.1.0 /usr/lib/libvtkRenderingAnnotation.so.9.1.0 /usr/lib/libvtkRenderingContext2D.so.9.1.0 /usr/lib/libvtkRenderingFreeType.so.9.1.0 /usr/lib/libfreetype.so /usr/lib/libvtkImagingSources.so.9.1.0 /usr/lib/libvtkIOImage.so.9.1.0 /usr/lib/libvtkImagingCore.so.9.1.0 /usr/lib/libvtkRenderingOpenGL2.so.9.1.0 /usr/lib/libvtkRenderingUI.so.9.1.0 /usr/lib/libvtkRenderingCore.so.9.1.0 /usr/lib/libvtkCommonColor.so.9.1.0 /usr/lib/libvtkFiltersGeometry.so.9.1.0 /usr/lib/libvtkFiltersSources.so.9.1.0 /usr/lib/libvtkFiltersGeneral.so.9.1.0 /usr/lib/libvtkCommonComputationalGeometry.so.9.1.0 /usr/lib/libvtkFiltersCore.so.9.1.0 /usr/lib/libvtkCommonExecutionModel.so.9.1.0 /usr/lib/libvtkCommonDataModel.so.9.1.0 /usr/lib/libvtkCommonMisc.so.9.1.0 /usr/lib/libvtkCommonTransforms.so.9.1.0 /usr/lib/libvtkCommonMath.so.9.1.0 /usr/lib/libvtkkissfft.so.9.1.0 /usr/lib/libGLEW.so /usr/lib/libX11.so /usr/lib/libQt5OpenGL.so.5.15.2 /usr/lib/libQt5Widgets.so.5.15.2 /usr/lib/libQt5Gui.so.5.15.2 /usr/lib/libQt5Core.so.5.15.2 /usr/lib/libvtkCommonCore.so.9.1.0 -pthread /usr/lib/libtbb.so.12.5 -lgomp -lpthread /usr/lib/libvtksys.so.9.1.0 -ldl -Wl,-rpath-link,/usr/lib/openmpi

</code>```

答:
I just got the code in https://pcl.readthedocs.io/projects/tutorials/en/master/greedy_projection.html#greedy-triangulation, I copied and pasted the code .cpp and the CMakeList.txt explained on the tutorial and that one is working fine for me.

Taking a look on the diffs from your code I discovered when I compile without the "common io" in find_package its compiling without problems.I'm using PCL 1.2 and ubuntu 20.04.

In my case, the changes in CMakeList is like:
find_package(PCL 1.2 REQUIRED COMPONENTS)

Title: How to solve PCL linking errors?

Body:
EDIT: Updated code

I'm using PCL library to generate a mesh from point clouds. This is the code, based on the Greedy Triangulation tutorial in the PCL docs:

#include <pcl/point_types.h>
#include <pcl/common/io.h>
#include <pcl/io/ply_io.h>
#include <pcl/search/kdtree.h>
#include <pcl/features/normal_3d.h>
#include <pcl/surface/gp3.h>
#include <pcl/io/obj_io.h>
#include <vector>

int main() {

    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);

    pcl::PCLPointCloud2 cloud1;
    pcl::PCLPointCloud2 cloud2;
    pcl::PCLPointCloud2 cloud3;

    pcl::io::loadPLYFile("../cam_1_2.ply", cloud1);
    pcl::io::loadPLYFile("../cam_2_3.ply", cloud2);
    pcl::io::loadPLYFile("../cam_3_4.ply", cloud3);

    cloud1 += cloud2 + cloud3;

    pcl::fromPCLPointCloud2(cloud1, *cloud);

    pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> n;
    pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>);
    pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>);

    tree->setInputCloud(cloud);
    n.setInputCloud(cloud);
    n.setSearchMethod(tree);
    n.setKSearch(20);
    n.compute(*normals);

    pcl::PointCloud<pcl::PointNormal>::Ptr cloudWithNormals(new pcl::PointCloud<pcl::PointNormal>);
    pcl::concatenateFields(*cloud, *normals, *cloudWithNormals);

    pcl::search::KdTree<pcl::PointNormal>::Ptr tree2 (new pcl::search::KdTree<pcl::PointNormal>);
    tree2->setInputCloud (cloudWithNormals);

    pcl::GreedyProjectionTriangulation<pcl::PointNormal> gp3;
    pcl::PolygonMesh triangles;

    gp3.setSearchRadius(0.025);

    gp3.setMu(2.5);
    gp3.setMaximumNearestNeighbors(100);
    gp3.setMaximumSurfaceAngle(M_PI/4);
    gp3.setMinimumAngle(M_PI/18);
    gp3.setMaximumAngle(2 * M_PI / 3);
    gp3.setNormalConsistency(false);

    gp3.setInputCloud(cloudWithNormals);
    gp3.setSearchMethod(tree2);
    gp3.reconstruct(triangles);

    std::vector<int> parts = gp3.getPartIDs();
    std::vector<int> states = gp3.getPointStates();

    pcl::io::saveOBJFile("../cam_1_2.obj", triangles);

    return 0;
}

This is the CMakeLists file i'm using to build this:

cmake_minimum_required(VERSION 3.1 FATAL_ERROR)

project(TestProject)

find_package(PCL 1.12 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(Test main.cpp)
target_link_libraries(Test ${PCL_LIBRARIES} liblz4.so libpthread.so)

This is the make output in terminal:

 make                                                                                2 ↵
Consolidate compiler generated dependencies of target Test
[ 50%] Building CXX object CMakeFiles/Test.dir/main.cpp.o
[100%] Linking CXX executable Test
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o: in function `pcl::search::KdTree<pcl::PointXYZ, pcl::KdTreeFLANN<pcl::PointXYZ, flann::L2_Simple<float> > >::KdTree(bool)':
main.cpp:(.text._ZN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEC2Eb[_ZN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEC5Eb]+0x5e): undefined reference to `pcl::search::Search<pcl::PointXYZ>::Search(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o: in function `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::OrganizedNeighbor(bool, float, unsigned int)':
main.cpp:(.text._ZN3pcl6search17OrganizedNeighborINS_8PointXYZEEC2Ebfj[_ZN3pcl6search17OrganizedNeighborINS_8PointXYZEEC5Ebfj]+0x66): undefined reference to `pcl::search::Search<pcl::PointXYZ>::Search(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x20): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getName[abi:cxx11]() const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x28): undefined reference to `pcl::search::Search<pcl::PointXYZ>::setSortedResults(bool)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x30): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getSortedResults()'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x50): undefined reference to `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::nearestKSearch(pcl::PointXYZ const&, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x58): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x60): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x68): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, int, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x70): undefined reference to `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::radiusSearch(pcl::PointXYZ const&, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x78): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x80): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE[_ZTVN3pcl6search17OrganizedNeighborINS_8PointXYZEEE]+0x88): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, double, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x20): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getName[abi:cxx11]() const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x30): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getSortedResults()'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x58): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x60): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x68): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, int, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x78): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x80): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE[_ZTVN3pcl6search6KdTreeINS_8PointXYZENS_11KdTreeFLANNIS2_N5flann9L2_SimpleIfEEEEEE]+0x88): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, double, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x20): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getName[abi:cxx11]() const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x28): undefined reference to `pcl::search::Search<pcl::PointXYZ>::setSortedResults(bool)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x30): undefined reference to `pcl::search::Search<pcl::PointXYZ>::getSortedResults()'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x38): undefined reference to `pcl::search::Search<pcl::PointXYZ>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&, std::shared_ptr<std::vector<int, std::allocator<int> > const> const&)'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x58): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x60): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(int, int, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x68): undefined reference to `pcl::search::Search<pcl::PointXYZ>::nearestKSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, int, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x78): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x80): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(int, double, std::vector<int, std::allocator<int> >&, std::vector<float, std::allocator<float> >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o:(.data.rel.ro._ZTVN3pcl6search6SearchINS_8PointXYZEEE[_ZTVN3pcl6search6SearchINS_8PointXYZEEE]+0x88): undefined reference to `pcl::search::Search<pcl::PointXYZ>::radiusSearch(pcl::PointCloud<pcl::PointXYZ> const&, std::vector<int, std::allocator<int> > const&, double, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >&, unsigned int) const'
/usr/bin/ld: CMakeFiles/Test.dir/main.cpp.o: in function `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::setInputCloud(std::shared_ptr<pcl::PointCloud<pcl::PointXYZ> const> const&, std::shared_ptr<std::vector<int, std::allocator<int> > const> const&)':
main.cpp:(.text._ZN3pcl6search17OrganizedNeighborINS_8PointXYZEE13setInputCloudERKSt10shared_ptrIKNS_10PointCloudIS2_EEERKS4_IKSt6vectorIiSaIiEEE[_ZN3pcl6search17OrganizedNeighborINS_8PointXYZEE13setInputCloudERKSt10shared_ptrIKNS_10PointCloudIS2_EEERKS4_IKSt6vectorIiSaIiEEE]+0x1ea): undefined reference to `pcl::search::OrganizedNeighbor<pcl::PointXYZ>::estimateProjectionMatrix()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/Test.dir/build.make:154: Test] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/Test.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

I have found a few related issues people have encountered similar to this and I have tried all the solutions provided without any help.

I am building this on Arch linux 1.4, PCL versuin 1.12.1

EDIT: Following is the output of make -j6 VERBOSE=1

❯ make -j6 VERBOSE=1
/usr/local/bin/cmake -S/home/beany/Documents/projects/pc2mesh -B/home/beany/Documents/projects/pc2mesh/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /home/beany/Documents/projects/pc2mesh/build/CMakeFiles /home/beany/Documents/projects/pc2mesh/build//CMakeFiles/progress.marks
make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/beany/Documents/projects/pc2mesh/build'
make  -f CMakeFiles/Test.dir/build.make CMakeFiles/Test.dir/depend
make[2]: Entering directory '/home/beany/Documents/projects/pc2mesh/build'
cd /home/beany/Documents/projects/pc2mesh/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/beany/Documents/projects/pc2mesh /home/beany/Documents/projects/pc2mesh /home/beany/Documents/projects/pc2mesh/build /home/beany/Documents/projects/pc2mesh/build /home/beany/Documents/projects/pc2mesh/build/CMakeFiles/Test.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/beany/Documents/projects/pc2mesh/build'
make  -f CMakeFiles/Test.dir/build.make CMakeFiles/Test.dir/build
make[2]: Entering directory '/home/beany/Documents/projects/pc2mesh/build'
[ 50%] Building CXX object CMakeFiles/Test.dir/main.cpp.o
/opt/cuda/bin/g++ -DBOOST_ATOMIC_DYN_LINK -DBOOST_ATOMIC_NO_LIB -DBOOST_DATE_TIME_DYN_LINK -DBOOST_DATE_TIME_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_FILESYSTEM_NO_LIB -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_IOSTREAMS_NO_LIB -DBOOST_SERIALIZATION_DYN_LINK -DBOOST_SERIALIZATION_NO_LIB -DBOOST_SYSTEM_DYN_LINK -DBOOST_SYSTEM_NO_LIB -DDISABLE_PCAP -DDISABLE_PNG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -Dkiss_fft_scalar=double -isystem /usr/include/pcl-1.12 -isystem /usr/include/eigen3 -isystem /usr/include/ni -isystem /usr/include/openni2 -isystem /usr/include/vtk -isystem /usr/include/freetype2 -isystem /usr/include/qt -isystem /usr/include/qt/QtOpenGL -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtCore -isystem /usr/lib/qt/mkspecs/linux-g++ -msse4.2 -mfpmath=sse -march=native -mavx2 -pthread -fopenmp -fPIC -MD -MT CMakeFiles/Test.dir/main.cpp.o -MF CMakeFiles/Test.dir/main.cpp.o.d -o CMakeFiles/Test.dir/main.cpp.o -c /home/beany/Documents/projects/pc2mesh/main.cpp
[100%] Linking CXX executable Test
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/Test.dir/link.txt --verbose=1
/opt/cuda/bin/g++ -rdynamic CMakeFiles/Test.dir/main.cpp.o -o Test  -Wl,-rpath,/usr/lib/openmpi /usr/lib/libpcl_io.so -lOpenNI /usr/lib/libusb-1.0.so -lOpenNI2 /usr/lib/libusb-1.0.so /usr/lib/libvtkChartsCore.so.9.1.0 /usr/lib/libvtkInteractionImage.so.9.1.0 /usr/lib/libvtkIOGeometry.so.9.1.0 /usr/lib/libvtkIOPLY.so.9.1.0 /usr/lib/libvtkRenderingLOD.so.9.1.0 /usr/lib/libvtkViewsContext2D.so.9.1.0 /usr/lib/libvtkGUISupportQt.so.9.1.0 -llz4 -lpthread /usr/lib/libpcl_octree.so /usr/lib/libpcl_common.so /usr/lib/libboost_system.so.1.78.0 /usr/lib/libboost_filesystem.so.1.78.0 /usr/lib/libboost_atomic.so.1.78.0 /usr/lib/libboost_date_time.so.1.78.0 /usr/lib/libboost_iostreams.so.1.78.0 /usr/lib/libboost_serialization.so.1.78.0 /usr/lib/libjsoncpp.so /usr/lib/libvtkViewsCore.so.9.1.0 /usr/lib/libvtkInteractionWidgets.so.9.1.0 /usr/lib/libvtkFiltersModeling.so.9.1.0 /usr/lib/libvtkInteractionStyle.so.9.1.0 /usr/lib/libvtkFiltersExtraction.so.9.1.0 /usr/lib/libvtkIOLegacy.so.9.1.0 /usr/lib/libvtkIOCore.so.9.1.0 /usr/lib/libvtkRenderingAnnotation.so.9.1.0 /usr/lib/libvtkRenderingContext2D.so.9.1.0 /usr/lib/libvtkRenderingFreeType.so.9.1.0 /usr/lib/libfreetype.so /usr/lib/libvtkImagingSources.so.9.1.0 /usr/lib/libvtkIOImage.so.9.1.0 /usr/lib/libvtkImagingCore.so.9.1.0 /usr/lib/libvtkRenderingOpenGL2.so.9.1.0 /usr/lib/libvtkRenderingUI.so.9.1.0 /usr/lib/libvtkRenderingCore.so.9.1.0 /usr/lib/libvtkCommonColor.so.9.1.0 /usr/lib/libvtkFiltersGeometry.so.9.1.0 /usr/lib/libvtkFiltersSources.so.9.1.0 /usr/lib/libvtkFiltersGeneral.so.9.1.0 /usr/lib/libvtkCommonComputationalGeometry.so.9.1.0 /usr/lib/libvtkFiltersCore.so.9.1.0 /usr/lib/libvtkCommonExecutionModel.so.9.1.0 /usr/lib/libvtkCommonDataModel.so.9.1.0 /usr/lib/libvtkCommonMisc.so.9.1.0 /usr/lib/libvtkCommonTransforms.so.9.1.0 /usr/lib/libvtkCommonMath.so.9.1.0 /usr/lib/libvtkkissfft.so.9.1.0 /usr/lib/libGLEW.so /usr/lib/libX11.so /usr/lib/libQt5OpenGL.so.5.15.2 /usr/lib/libQt5Widgets.so.5.15.2 /usr/lib/libQt5Gui.so.5.15.2 /usr/lib/libQt5Core.so.5.15.2 /usr/lib/libvtkCommonCore.so.9.1.0 -pthread /usr/lib/libtbb.so.12.5 -lgomp -lpthread /usr/lib/libvtksys.so.9.1.0 -ldl -Wl,-rpath-link,/usr/lib/openmpi


问:
Why can't my Github Action read the last command line argument? But my PC works fine
This is a GitHub Action that will execute a python file in the shell with multiple command line arguments, but the last argument cannot be read.
my code

the github action result

my pc result

the action's yaml file

答: As mentionned by GuiFalourd, your script uses array from 1 to 9, where it should use 0 to 8 : sys.argv[0] ... sys.argv[8]


问:
Is it possible to run multiple threads simultaneously on a same core?
I am calling a Flask server(running with 64 gunicorn workers) via http with ThreadPoolExecutor to test execution time.

Both(test script and Flask server) are running on the same host. Inside the Flask endpoint, there is a DB(Postgres) call.

Machine stats (11 cores, 16 GB ram)

Test script:

```<code>class StressTest():

    def __init__(self, max_workers):
        self.__max_workers = max_workers

    def __async_test(self, x=range(1000)):
        with ThreadPoolExecutor(max_workers=self.__max_workers) as executor:
            futures = [
                executor.submit(
                    self.__test,
                    n=n
                )
                for n in x
            ]

        for future in futures:
            try:
                future.result()
            except Exception as e:
                raise Exception(e)

    def __test(self, n):
        # Rest call

    def run(self):
        start_time = datetime.now()
        self.__async_test()

        duration = datetime.now() - start_time
        self.logger.info(f"duration for the process is {duration.total_seconds()} seconds")

if __name__ == "__main__":
    StressTest(1).run()
    StressTest(2).run()
    StressTest(4).run()
    .......
</code>```

Results as follows:

No of threads
Execution time (s)

1
50

2
25

4
12

8
8.5

16
8

32
7.5

64
7.5

My question is why execution time is saturating after 8 threads? Isn't it possible to run multiple threads at the same time in a given core?

Any given time, only 11 threads are running (via htop) during the test.

Please let me know if you want additional information about my test. Thank you!

答:
It (ThreadPoolExecutor) utilizes at most 32 CPU cores for CPU bound tasks which release the GIL

It's that latter condition which should worry you. "GIL" is the Global Interpreter Lock. Your Python runtime has only one such lock, that's why it is called "Global". And it's used for pretty much anything that works with memory. Even a simple a=b can require the GIL. Statements like these are therefore not faster if more cores are available - there simply aren't more locks.

However, I/O operations are designed so that they do not need the GIL while the OS is working on the operation. In this case, multiple cores could help a bit - but here the OS typically is waiting on other hardware, not the CPU.

Postgres can use multiple threads, so you can have multiple threads execute multiple queries. This would likely give a speed-up for that part of the processing. As noted in the comments, Amdahl's Law tells you that a program with mixed multi-threaded and single-threaded parts will be limited by its single-threaded parts if enough cores are available. And in Python, the GIL behaves as that single-threaded part.

Body:
I am calling a Flask server(running with 64 gunicorn workers) via http with ThreadPoolExecutor to test execution time.

Both(test script and Flask server) are running on the same host. Inside the Flask endpoint, there is a DB(Postgres) call.

Machine stats (11 cores, 16 GB ram)

Test script:

class StressTest():

    def __init__(self, max_workers):
        self.__max_workers = max_workers

    def __async_test(self, x=range(1000)):
        with ThreadPoolExecutor(max_workers=self.__max_workers) as executor:
            futures = [
                executor.submit(
                    self.__test,
                    n=n
                )
                for n in x
            ]

        for future in futures:
            try:
                future.result()
            except Exception as e:
                raise Exception(e)

    def __test(self, n):
        # Rest call

    def run(self):
        start_time = datetime.now()
        self.__async_test()

        duration = datetime.now() - start_time
        self.logger.info(f"duration for the process is {duration.total_seconds()} seconds")

if __name__ == "__main__":
    StressTest(1).run()
    StressTest(2).run()
    StressTest(4).run()
    .......

Results as follows:

No of threads
Execution time (s)

1
50

2
25

4
12

8
8.5

16
8

32
7.5

64
7.5

My question is why execution time is saturating after 8 threads? Isn't it possible to run multiple threads at the same time in a given core?

Any given time, only 11 threads are running (via htop) during the test.

Please let me know if you want additional information about my test. Thank you!


问:
Can we use github repository as an artifact while creating maven project?
I've implemented a maven library and published it to GitHub. Now I wanted to use this repository as an archetype to create another maven project (without maven central repo) like below

When I tried this it's giving the below error

Is there any way to do this?

答:
You'll need to have a git repo which defines 'archetype' project and then package and install it's generated artifact into the github hosted artifact repository.

See this maven guide to define the archrtype

https://maven.apache.org/guides/mini/guide-creating-archetypes.html

And use github actions to publish the artifact.


问:
Use active record to find a record by month and day, ignoring year and time
I have a model (Entries) with five years worth of records (one record per day). I need a method that, when passed a date object such as 2011-12-25 00:00:00, will show me ALL the records that have happened on 12/25 (querying against the :created_at column), regardless of the year or time that's passed.

RoR 3.0.9 / Ruby 1.9.2p290

答:
You can use the MONTH and DAY values of mysql.  Maybe something like:</p>

```<code>Model.where("MONTH(created_at) = ? and DAY(created_at) = ?", somedate.month, somedate.day)
</code>```

Body:
You can use the MONTH and DAY values of mysql.  Maybe something like:

Model.where("MONTH(created_at) = ? and DAY(created_at) = ?", somedate.month, somedate.day)


问:
Unable to cast object of type 'MS.Internal.NamedObject' to type 'System.Data.DataRowView'
I have this code to retrieve data from a datagrid and then store then in another datatable. But I am getting the exception as:
"Unable to cast object of type 'MS.Internal.NamedObject' to type 'System.Data.DataRowView'." This exception comes after "dt.Rows.Add(dr.ItemArray)"

Please do let me know if there are any faults, or any additional information is needed.

Code:

```<code> DataTable dt = new DataTable();
         DataColumn c1 = new DataColumn("IsActive", typeof(bool));
         dt.Columns.Add(c1);

         DataColumn c2 = new DataColumn("DataGridTextBox_QCList1", typeof(string));
         c2.MaxLength = 500;
         dt.Columns.Add(c2);

         DataColumn c3 = new DataColumn("DataGridTextBox_QCSummary", typeof(string));
         c3.MaxLength = 500;
         dt.Columns.Add(c3);

         DataColumn c4 = new DataColumn("DataGridComboxBox_Control", typeof(string));
         c4.MaxLength = 500;
         dt.Columns.Add(c4);

     foreach (DataRowView d in dtgQCNumbers.Items)
     {
    DataRow dr = d.Row;
    dt.Rows.Add(dr.ItemArray);
    dt.AcceptChanges();
     }
     foreach (DataRow row in dt.Rows)
     {
    qcId = row["QC_ID"].ToString();
    zipFolderPath = baseFolderPath;
    patternFiles = Directory.GetFiles(zipFolderPath, "*.zip");

    logMessage = "Unzipping file from path" + zipFolderPath + " \n file name:" + patternFiles[0];
    Common.LogMessage(logMessage);

    UnZipReleasePatch(zipFolderPath, patternFiles.First());
    //deploy release patch.
    logMessage = "Deploying files" + zipFolderPath;
    Common.LogMessage(logMessage);
    DeployFiles();
}
</code>```

答:
if you don't need to add new rows you can simply write in XAML :

CanUserAddRows="False"

and the placholder will be lost, so you can iterate until you will turn it on again.

Body:
I have this code to retrieve data from a datagrid and then store then in another datatable. But I am getting the exception as:
"Unable to cast object of type 'MS.Internal.NamedObject' to type 'System.Data.DataRowView'." This exception comes after "dt.Rows.Add(dr.ItemArray)"

Please do let me know if there are any faults, or any additional information is needed.

Code:

 DataTable dt = new DataTable();
         DataColumn c1 = new DataColumn("IsActive", typeof(bool));
         dt.Columns.Add(c1);

         DataColumn c2 = new DataColumn("DataGridTextBox_QCList1", typeof(string));
         c2.MaxLength = 500;
         dt.Columns.Add(c2);

         DataColumn c3 = new DataColumn("DataGridTextBox_QCSummary", typeof(string));
         c3.MaxLength = 500;
         dt.Columns.Add(c3);

         DataColumn c4 = new DataColumn("DataGridComboxBox_Control", typeof(string));
         c4.MaxLength = 500;
         dt.Columns.Add(c4);

     foreach (DataRowView d in dtgQCNumbers.Items)
     {
    DataRow dr = d.Row;
    dt.Rows.Add(dr.ItemArray);
    dt.AcceptChanges();
     }
     foreach (DataRow row in dt.Rows)
     {
    qcId = row["QC_ID"].ToString();
    zipFolderPath = baseFolderPath;
    patternFiles = Directory.GetFiles(zipFolderPath, "*.zip");

    logMessage = "Unzipping file from path" + zipFolderPath + " \n file name:" + patternFiles[0];
    Common.LogMessage(logMessage);

    UnZipReleasePatch(zipFolderPath, patternFiles.First());
    //deploy release patch.
    logMessage = "Deploying files" + zipFolderPath;
    Common.LogMessage(logMessage);
    DeployFiles();
}


问:
Run dockerd.exe to start Docker daemon
I know that in order to run Docker daemon, I should stop Docker Window and run dockerd.exe in resources folder. However when I want to execute it by command prompt, I get the error below:

```<code>time="2020-09-10T15:22:48.798108400+04:30" level=info msg="Starting up"
failed to start daemon: a required service is not installed, ensure the Containers feature is
installed: Access is denied.
</code>```

can someone help me how to solve the problem or suggest other ways to run Docker daemon?

答:
Download docker.exe (cli) and dockerd.exe (service) to a local folder. Add the folder to path. Add the folder to $PATH, in environment variables. in the example below C:\Docker\

https://download.docker.com/win/static/stable/x86_64/

Create a new user group under "Edit local users and group". Name is docker-users or update the Json file below. Add anyone who needs to run docker to this group.

Create a new config file daemon.json

```<code>{
                "group": "docker-users",
}
</code>```

Run this in powershell as administrator

```<code>New-Service -Name Docker -BinaryPathName "C:\docker\dockerd.exe  --run-service --config-file C:\docker\daemon.json" -DisplayName "Docker Engine" -StartupType "Automatic"
</code>```

Bonus: Older Docker-compose cli is available here,
https://github.com/docker/compose/releases

NOTE: I had some issues with the service starting up automatically after reboot.

Title: Run dockerd.exe to start Docker daemon

Body:
I know that in order to run Docker daemon, I should stop Docker Window and run dockerd.exe in resources folder. However when I want to execute it by command prompt, I get the error below:

time="2020-09-10T15:22:48.798108400+04:30" level=info msg="Starting up"
failed to start daemon: a required service is not installed, ensure the Containers feature is
installed: Access is denied.

can someone help me how to solve the problem or suggest other ways to run Docker daemon?

Body:
Download docker.exe (cli) and dockerd.exe (service) to a local folder. Add the folder to path. Add the folder to $PATH, in environment variables. in the example below C:\Docker\

https://download.docker.com/win/static/stable/x86_64/

Create a new user group under "Edit local users and group". Name is docker-users or update the Json file below. Add anyone who needs to run docker to this group.

Create a new config file daemon.json

{
                "group": "docker-users",
}

Run this in powershell as administrator

New-Service -Name Docker -BinaryPathName "C:\docker\dockerd.exe  --run-service --config-file C:\docker\daemon.json" -DisplayName "Docker Engine" -StartupType "Automatic"

Bonus: Older Docker-compose cli is available here,
https://github.com/docker/compose/releases

NOTE: I had some issues with the service starting up automatically after reboot.


问:
How to decode column value from rare label by matching column names
I have two dataframes like as shown below

```<code>import numpy as np
import pandas as pd
from numpy.random import default_rng
rng = default_rng(100)
cdf = pd.DataFrame({'Id':[1,2,3,4,5],
                   'grade': rng.choice(list('ACD'),size=(5)),
                   'dash': rng.choice(list('PQRS'),size=(5)),
                   'dumeel': rng.choice(list('QWER'),size=(5)),
                   'dumma': rng.choice((1234),size=(5)),
                   'target': rng.choice([0,1],size=(5))
})

tdf = pd.DataFrame({'Id': [1,1,1,1,3,3,3],
                   'feature': ['grade=Rare','dash=Q','dumma=rare','dumeel=R','dash=Rare','dumma=rare','grade=D'],
                   'value': [0.2,0.45,-0.32,0.56,1.3,1.5,3.7]})
</code>```

My objective is to

a) Replace the Rare or rare values in feature column of tdf dataframe by original value from cdf dataframe.

b) To identify original value, we can make use of the string before = Rare or =rare or = rare etc. That string represents the column name in cdf dataframe (from where original value to replace rare can be found)

I was trying something like the below but not sure how to go from here

```<code>replace_df = cdf.merge(tdf,how='inner',on='Id')
replace_df ["replaced_feature"] = np.where(((replace_df["feature"].str.contains('rare',regex=True)]) & (replace_df["feature"].str.split('='))])
</code>```

I have to apply this on a big data where I have million rows and more than 1000 replacements to be made like this.

I expect my output to be like as shown below

答:
Here is one possible approach using MultiIndex.map to substitute values from cdf into tdf:

s = tdf['feature'].str.split('=')
m = s.str[1].isin(['rare', 'Rare'])
v = tdf[m].set_index(['Id', s[m].str[0]]).index.map(cdf.set_index('Id').stack())

tdf.loc[m, 'feature'] = s[m].str[0] + '=' + v.astype(str)
```
<hr />
```print(tdf)

   Id     feature  value
0   1     grade=D   0.20
1   1      dash=Q   0.45
2   1  dumma=1123  -0.32
3   1    dumeel=R   0.56
4   3      dash=P   1.30
5   3   dumma=849   1.50
6   3     grade=D   3.70
```

Body:
I have two dataframes like as shown below

import numpy as np
import pandas as pd
from numpy.random import default_rng
rng = default_rng(100)
cdf = pd.DataFrame({'Id':[1,2,3,4,5],
                   'grade': rng.choice(list('ACD'),size=(5)),
                   'dash': rng.choice(list('PQRS'),size=(5)),
                   'dumeel': rng.choice(list('QWER'),size=(5)),
                   'dumma': rng.choice((1234),size=(5)),
                   'target': rng.choice([0,1],size=(5))
})

tdf = pd.DataFrame({'Id': [1,1,1,1,3,3,3],
                   'feature': ['grade=Rare','dash=Q','dumma=rare','dumeel=R','dash=Rare','dumma=rare','grade=D'],
                   'value': [0.2,0.45,-0.32,0.56,1.3,1.5,3.7]})

My objective is to

a) Replace the Rare or rare values in feature column of tdf dataframe by original value from cdf dataframe.

b) To identify original value, we can make use of the string before = Rare or =rare or = rare etc. That string represents the column name in cdf dataframe (from where original value to replace rare can be found)

I was trying something like the below but not sure how to go from here

replace_df = cdf.merge(tdf,how='inner',on='Id')
replace_df ["replaced_feature"] = np.where(((replace_df["feature"].str.contains('rare',regex=True)]) & (replace_df["feature"].str.split('='))])

I have to apply this on a big data where I have million rows and more than 1000 replacements to be made like this.

I expect my output to be like as shown below

Body:
Here is one possible approach using MultiIndex.map to substitute values from cdf into tdf:

s = tdf['feature'].str.split('=')
m = s.str[1].isin(['rare', 'Rare'])
v = tdf[m].set_index(['Id', s[m].str[0]]).index.map(cdf.set_index('Id').stack())

tdf.loc[m, 'feature'] = s[m].str[0] + '=' + v.astype(str)

print(tdf)

   Id     feature  value
0   1     grade=D   0.20
1   1      dash=Q   0.45
2   1  dumma=1123  -0.32
3   1    dumeel=R   0.56
4   3      dash=P   1.30
5   3   dumma=849   1.50
6   3     grade=D   3.70


问:
Open specific URL from Outlook with Chrome
Our company use IE as the default browser, but certain application we are working with require chrome. since we can't abandon IE, we need to open specific \ certain links with chrome, only with outlook.
I tried the following vba, which works great, but open automaticlly.

```<code>Sub LaunchURL(itm As MailItem)

Dim bodyString As String
Dim bodyStringSplitLine
Dim bodyStringSplitWord
Dim splitLine
Dim splitWord

bodyString = itm.Body
bodyStringSplitLine = Split(bodyString, vbCrLf)

For Each splitLine In bodyStringSplitLine
    bodyStringSplitWord = Split(splitLine, " ")

    For Each splitWord In bodyStringSplitWord
        If Left(splitWord, 7) = "http://" Then
            Shell ("C:\Program Files\Google\Chrome\Application\chrome.exe" & " " & splitWord)
        End If
    Next

Next

Set itm = Nothing

End Sub

Private Sub test()
    Dim currItem As MailItem
    Set currItem = ActiveInspector.CurrentItem
    LaunchURL currItem
End Sub
</code>```

Is there any way to make this script work when the users clicks the url and not automaticlly ? or therefore any way to make this work when the users read the message (so he can unread and when read it will open when he needs to) ?

Sorry in advance for my bad english.

答:
Is there any way to make this script work when the users clicks the url and not automaticlly ?

Nope. There is no trivial way for getting this working per URL. The Outlook object mode doesn't provide anything for handling hyperlinks clicks. The best what you could do is to replace links with your owns and tracking this by navigating to your URLs and then forwarding to the original ones.

or therefore any way to make this work when the users read the message (so he can unread and when read it will open when he needs to) ?

You can handle the SelectionChange event of the Explorer class which is fired when the user selects a different or additional Microsoft Outlook item programmatically or by interacting with the user interface. This event also occurs when the user (either programmatically or via the user interface) clicks or switches to a different folder that contains items, because Outlook automatically selects the first item in that folder.

For inspector windows you may consider handling the Inspectors.NewInspector event which is fired whenever a new inspector window is opened, either as a result of user action or through program code.

Body:
Our company use IE as the default browser, but certain application we are working with require chrome. since we can't abandon IE, we need to open specific \ certain links with chrome, only with outlook.
I tried the following vba, which works great, but open automaticlly.

Sub LaunchURL(itm As MailItem)

Dim bodyString As String
Dim bodyStringSplitLine
Dim bodyStringSplitWord
Dim splitLine
Dim splitWord

bodyString = itm.Body
bodyStringSplitLine = Split(bodyString, vbCrLf)

For Each splitLine In bodyStringSplitLine
    bodyStringSplitWord = Split(splitLine, " ")

    For Each splitWord In bodyStringSplitWord
        If Left(splitWord, 7) = "http://" Then
            Shell ("C:\Program Files\Google\Chrome\Application\chrome.exe" & " " & splitWord)
        End If
    Next

Next

Set itm = Nothing

End Sub

Private Sub test()
    Dim currItem As MailItem
    Set currItem = ActiveInspector.CurrentItem
    LaunchURL currItem
End Sub

Is there any way to make this script work when the users clicks the url and not automaticlly ? or therefore any way to make this work when the users read the message (so he can unread and when read it will open when he needs to) ?

Sorry in advance for my bad english.